My old subdomain urls look something like:
www.newyork.website.co.uk
I want to redirect it now to:
www.website.com/city/newyork
However I have over 2,000 cities and just want to add a wildcard redirect. How do I go about doing this in my htaccess file?
eg www.*.website.co.uk redirects to www.website.co.uk/city/*
THis is so far over myhead but this is what I have tried to muddle together:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.domain.co.uk/city/%{REQUEST_URI} [R=301,L]
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?((?!www\.)[^.]+)\.(website\.co\.uk)$ [NC]
RewriteRule ^/?$ http://www.%2/city/%1 [R=302,L]
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.