Jump to content
Sign in to follow this  
ben03

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]

</IfModule>

Any pointers here would be greatly appreciated!

Thanks

Share this post


Link to post
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.

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

I don't think you'd want to do that, some of those rules you do want to be the last rule processed.  You need to order them based on priority though, which rules do you want to happen first in which order.

Share this post


Link to post
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
Sign in to follow this  

×