We're working on a magento store at the moment where multiple 301 redirects have previously been implemented. The original .htaccess file has lots of rules in such as the following:
RedirectMatch 301 ^/original-page.html http://www.yourdomain.co.uk/our-new-directory/new-page.html
RedirectMatch 301 ^/original-page2.html http://www.yourdomain.co.uk/our-new-directory/new-page2.html
RedirectMatch 301 ^/original-page3.html http://www.yourdomain.co.uk/our-new-directory/new-page3.html
The website has now had a new TLD setup, so if you visit http://www.yourdomain.de/original-page.html , you're getting redirected to http://www.yourdomain.co.uk/our-new-directory/new-page.html .
What I want to do is have it so that we have the following:
Someone types in:
http://www.yourdomain.co.uk/original-page.html and gets redirected to http://www.yourdomain.co.uk/our-new-directory/new-page.html
AND
http://www.yourdomain.de/original-page.html and gets redirected to http://www.yourdomain.de/our-new-directory/new-page.html
Essentially, the redirect should take into account the TLD that the user is on. The main reason for this is that many pages on the website have URLs where they've been 301 redirected.
Any assistance on this would be brilliant.
Kind regards, Lewis
Place this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\. [NC]
RewriteRule ^original-page\.html$ http://%{HTTP_HOST}/our-new-directory/new-page.html [R=301,L]
You can just remove the hostname part of your redirects:
RedirectMatch 301 ^/original-page.html /our-new-directory/new-page.html
RedirectMatch 301 ^/original-page2.html /our-new-directory/new-page2.html
RedirectMatch 301 ^/original-page3.html /our-new-directory/new-page3.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.