Jump to content

rewrite 404 for files


XpertWorlock

Recommended Posts

Question, when doing a mod rewrite when it comes to long urls lets say for example ;

 

test.php?id=1

 

to

 

test/1

 

Now, all the files (css, js) are looking for them in the "1" directory which obviously does not exist.  I have listed everything as relative.

 

Is the fix for this to link everything absolute?

Link to comment
https://forums.phpfreaks.com/topic/205609-rewrite-404-for-files/
Share on other sites

I said absolute, then 'relative to root'. They essentially mean the same thing. If 'style.css' is in a folder called 'css', which is in the root directory, then it's path relative to root is '/css/style.css' which should references the exact same location as 'http://domain/css/style.css'.

I know what you mean, and I must be missing something, perhaps from the .htaccess file

 

The link to the css file in the test file, which is in the root directory:

<link rel="stylesheet" type="text/css" href="css/stylesheet.css"/>

 

So naturally searching

 

test.php?id=1

 

would work fine, but since it's being changed to

 

test/1

 

it isn't...  Sorry to repeat myself, but better more info than less.  Here is what the .htaccess file is.

 

Options +FollowSymLinks   
RewriteEngine On   
  
RewriteRule ^test/([0-9]+)/?$ test.php?id=$1 [NC]

 

Correct?

My problem was with WAMP.

 

A separate directory for a project was causing your '/' to look in the 'localhost' directory.

 

Is there any easy way of having it work both on a site and offline?

 

Example project being http://localhost/testProject

 

Looks for CSS or whatever in localhost directory and not testProject, or am I required to load everything straight into the localhost folder?

You'll need to set-up a 'proper' localhost set-up, by creating a vhost for each project you do.

 

I wrote/recorded this awhile ago before I knew a great deal about Apache configuration, but it get's the main points across...

http://phpacademy.info/forum/viewtopic.php?f=31&t=911

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.