Jump to content

htaccess rule not working


Recommended Posts

Hi there,

I am using a few of re-write rules, the last of which is not working. I assume it clashes with the others in some way?

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldurl.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.oldurl.co.uk$
RewriteRule (.*)$ http://www.newurl.co.uk/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteCond %{HTTP_HOST} ^newurl.co.uk$
RewriteRule (.*) http://www.newurl.co.uk/$1 [R=301,L]


Any pointers here would be greatly appreciated!


Link to comment
Share on other sites

All of those rules tell Apache that they should be the last rule matched, so if either of those other rules matches it's not going to execute any more.  In particular, if that second rule matches it will not execute the third one.

Link to comment
Share on other sites

Thank you justsomeguy. I am assuming it is the ',L' that needs removing from each of the brackets? That is the danger of taking different snippets from different tutorials I suppose. 

Thanks for the help :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...