Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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 :)

Posted

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.

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...