user398894
user398894

Reputation: 149

Remove .html Before Redirecting in Htaccess

I have the rule below which works perfectly, however My oldsite urls have .html and me newsite doesn't. Is it possible to strip the .html before redirecting? e.g.

www.oldsite.com/mypage.html

gets redirected to

www.newsite.com/subdir/mypage/

e.g.

Options +FollowSymLinks 
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.oldsite.com$ [NC]
RewriteRule ^(.*)$ http://www.newsite.co.uk/subdir/$1 [R=301,L]

Upvotes: 0

Views: 70

Answers (1)

undone
undone

Reputation: 7888

Options +FollowSymLinks 
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.oldsite.com$ [NC]
RewriteRule ^(.*)\.html$ http://www.newsite.co.uk/subdir/$1 [R=301,L]

so www.oldsite.com/mypage.html will be redirected to www.newsite.com/subdir/mypage

Upvotes: 1

Related Questions