Quantcast
Viewing all articles
Browse latest Browse all 12471

Reply To: Redirect all old HTML pages to new website pages

To redirect all old HTML website pages to your new site’s URL structure you would use this code below.  If your URL structure is 2 levels deep then you would use the /$1/$2 RedirectMatch code.  If your URL structure is 3 levels deep then you would use the /$1/$2/$3 RedirectMatch code, etc.

Source:  http://forum.ait-pro.com/forums/topic/htaccess-redirect-code-where-do-i-add-redirect-htaccess-code/

RedirectMatch 301 ^/([^/]+)/([^/.]+)\.html$ /$1/$2/
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/.]+)\.html$ /$1/$2/$3/

Or if you need to limit it by Host (domain name), you can use mod_rewrite:

RewriteCond %{HTTP_HOST} sitename.com [NC]
RewriteRule ^([^/]+)/([^/.]+)\.html$ /$1/$2/ [R=301,L]

RewriteCond %{HTTP_HOST} sitename.com [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html$ /$1/$2/$3/ [R=301,L]

Viewing all articles
Browse latest Browse all 12471

Trending Articles