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
Share on other sites

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?

Link to comment
Share on other sites

The rule is right, but the location of your script isn't, you haven't made it relative to root, it is relative to 'current directory', which because of the rewrite is '1'.

 

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.