Jump to content

Help! Images & CSS no longer work?


sean14592

Recommended Posts

Hey,

 

I'm new to using mod_rewrite, I have two url's I currently want to make more SEO friendly:

 

1) http://domain.com/dir/index.php?p=list&d=all

2) http://domain.com/dir/index.php?p=list&d=cat&c=2

 

I want these to turn into:

 

1) http://domain.com/list/all/

2) http://domain.com/list/cat/2/

 

 

Currently my .htaccess looks like this:

 

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)/(.*)/(.*)/ index.php?p=$1&d=$2&c=$3 [L]
RewriteRule (.*)/(.*)/ index.php?p=$1&d=$2 [L]

 

Now the rewrite itself works, however all my images and css have disappeared?

 

I'd appreciate it if anyone could help?

 

Kind Regards,

Sean

Link to comment
Share on other sites

Your srcs and hrefs are relative, looking like

<img src="folder/image.jpg" />

The browser will calculate the absolute path according to the current directory. After your rewriting of the first page it's "/list/all" so the browser will look for "/list/all/folder/image.jpg".

 

Use a leading slash to make them absolute paths. That way the current directory won't matter.

<img src="/folder/image.jpg" />

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.