Mod Rewrite Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Mod Rewrite Issue

Post by lettie_dude »

Hi

Just been browsing the forums to find a solution to my problem but am unable to find any. Hopefully it will be a fairly simple solution.

I have a rewrite condition:

RewriteRule ^cat-([0-9]+)/[A-Z0-9_-]+-([0-9]+)\.html$ cat.php?c=$1&sc=$2 [NC,L]

This should redirect a url as per example:

http://www.domain.com/cat-1/subcat_one-2.html ----- http://www.domain.com/cat.php?c=1&sc=2

And this does work. However all relative links in the page are broken. i.e. all links to css files, script files and images do not work. It seems the redirect is redirecting it keeping the folder structure which is incorrect as the folder does not really exist only in the domain. This is so I can seperate the redirect from being used on all pages and only on the cat.php page.

I have tried using the full domain as the address to direct to:

RewriteRule ^cat-([0-9]+)/[A-Z0-9_-]+-([0-9]+)\.html$ http://www.domain.com/cat.php?c=$1&sc=$2 [NC,L]

This worked but displayed the actual url as opposed to the pretty one!

I have also tried using a backslash:

RewriteRule ^cat-([0-9]+)/[A-Z0-9_-]+-([0-9]+)\.html$ /cat.php?c=$1&sc=$2 [NC,L]

This gave the same results as the first one.

Can anyone point me in the right direction. I do not want to go through the site changing all links from relative to absolute.

Cheers
Post Reply