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
https://forums.phpfreaks.com/topic/274164-help-images-css-no-longer-work/
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" />

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.