I have a site with a set of old .html and .php pages that have been put into a CMS.
Currently in the .htaccess file there are about 30 mod_alias redirects in the following form:
redirect 301 /oldpage1.html http://www.example.com/newpage1.php
redirect 301 /oldpage2.php http://www.example.com/newpage2.php
redirect 301 /oldpage3.php http://www.example.com/newpage3.php
But we want to use mod_rewrite to have pretty URLs in our CMS, which will take the form http://www.example.com/pagename.php
, so also have the following:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1
At the moment both are being applied together, which results in:
http://www.example.com/newpage1.php?page=oldpage1.html
How can I apply the rewrite rule only when no match has been made by the mod_alias redirect 301 statements, so that the following occurs:
http://www.example.com/oldpage1.html
-> redirects to ->
http://www.example.com/newpage1.php
-> which is treated as ->
http://www.example.com/index.php?page=/newpage1.php
Any hints would be very much appreciated? Thanks.