dealclickcouk
asked on
Apache Mod Rewrite with .htaccess redirecting site from old structure to new...
I have an existing site that has many indexed pages, the site structure is going to change with the next software update and so I want to do 301 (??) permanent redirect so that old links are redirected to the new structure.
URL's on old site are like:
domain.com/dept/kw.php
domain.com/cat/kw.php
domain.com/subcat/kw.php
The new structure is:
domain.com/dept/kw.html
domain.com/dept/cat/kw.htm
domain.com/dept/cat/subcat
The new site has an existing .htaccess file that redirects all to a index.php to process:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
What I'm not sure is, how do I within the same .htaccess get old links to redirect to new link structure permanantly and then with new structure redirect into the index.php ?
ASKER
Ok thx, so would I put this above or below, or in the existing redirect code?
Also does this do a 301 permanent redirect, ie so search engines will use the new link from then on etc...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RedirectMatch ^/dept/(.*)\.php$ /dept/$1.html
RedirectMatch ^/cat/(.*)\.php$ /cat/$1.html
and so on