Hi David,
I am having some problems with url rewriting and wonder if you could point out my errors please?
The .htaccess file looks like this
Options -MultiViews
RewriteEngine On
RewriteBase /
#add www subdomain
RewriteCond %{HTTP_HOST} ^pricescompare.co.uk [NC]
RewriteRule ^(.*)$ http://www.pricescompare.co.uk/$1 [L,R=301]
# index.php to /
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.pricescompare.co.uk/$1 [R=301,L]
# Category rewrites
RewriteRule ^(.*)/$ category.php?category_name=$1 [L]
# Page rewrites
RewriteRule ^privacy/$ privacy.php
RewriteRule ^about-us/$ about-us.php
RewriteRule ^register/$ register.php
RewriteRule ^login/$ login.php
RewriteRule ^logout/$ logout.phpIt was all working fine until I added this line
RewriteRule ^(.*)/$ category.php?category_name=$1 [L]
It doesn't seem to differentiate between the category rewrite and the page rewrites and directs all traffic to the category rewrite.
Here is a url that should go to the registration page but instead goes to the category page => http://www.pricescompare.co.uk/register/
Thanks in advance,
Simon


Hi Simon, It's down to
Hi Simon,
It's down to precedence - the new category rule that you added also matched all the subsequent rules, so it was applied and the other rules were never even checked.
All you'll need to do is move it to the end of .htaccess and that will let the higher level rules take priority and then anything-else/ will be redirected to category.php...
Cheers!
David.
Hi David, Thanks for that. I
Hi David,
Thanks for that.
I tried that but no joy, any other suggestions?
Thanks,
Simon
Compare Electricals
Hi Simon, I just noticed
Hi Simon,
I just noticed that the page rewrites do not have [L] (last rule) after them; so it would continue down to the category rewrite rule even if a match has been found - try replacing with:
RewriteRule ^privacy/$ privacy.php [L]RewriteRule ^about-us/$ about-us.php [L]
RewriteRule ^register/$ register.php [L]
RewriteRule ^login/$ login.php [L]
RewriteRule ^logout/$ logout.php [L]
Hope this helps!
Cheers,
David.
Hi David, Just an update as
Hi David,
Just an update as I was still having problems but figured it out eventually.
My directory structure looked something like this:
/admin/category.php
etc..
When I tried to access the /admin/ folder it always tried to load the category.php file. Not really sure why that was but the solution was to create a .htaccess file within the /admin/ folder and in it put this code.
RewriteEngine OnRewriteBase /admin/
All sorted now, hope it helps someone else!
Thanks again,
Simon
Compare Electricals