Forum Topic: Redirect particular domain
Hi there,
I have three domains on the same CMS install. I only want one domains short url redirecting not all of them eg:
example.co.uk/short_url to link to example.co.uk/folder/folder2/long_url
but NOT
example.com.au/short_url to link to example.com.au/folder/folder2/long_url
Thanks
6 Replies to “Redirect particular domain”
Hi Steven,
Try placing this code in the root .htaccess file at example.co.uk
:
RedirectMatch 301 ^/short_url http://example.co.uk/folder/folder2/long_url
That should redirect all requests for example.co.uk/short_url
to example.co.uk/folder/folder2/long_url
, without affecting any URLs on the other domains. You may need to change the regex to account for any dynamic variables in either match, depending on URL formats and what’s required.
Test thoroughly!
Thanks Jeff however all three domains use the same CMS (expressionengine) and so the root .htaccess file is the same for all domains.
The code above also links .com.au
and co.nz
domains.
Do you have any other ideas?
Thanks for your help
Ah, I see.. Yes the question about redirecting multisite networks (WP, EE, etc.) has come up before but as far as I know is yet unresolved. People are working on it, and it has been reported that something along these lines will work:
RewriteCond %{HTTP_HOST} ^example.co.uk [NC]
RewriteRule ^/short_url http://example.co.uk/folder/folder2/long_url [R=301,NC,L]
..but I haven’t had a chance to test yet. Hopefully it is useful!
Thanks but it didn’t work. I’ll play around and see if I can find the answer. Thanks
Also in your book under the tile “Force download of specific file-types” your code only works sometimes. Modern browsers still bypass the octet-stream by itself.
You need to set the Content-Disposition as attachment so I use something like
<FilesMatch "\.(mov|mp3|mp4|pdf|doc|docx|xls|ppt|potx|dotx)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
I have learnt heaps through the book so thanks.
Thank you for the tip on Content-Disposition, I will look into it and update the book accordingly. Hopefully there is a solution for the redirect in EE! Good luck.
PS, I combined/edited your previous posts into one :)
Hi Jeff,
That code you supplied earlier almost worked. I just needed to escape the full stops.
RewriteCond %{HTTP_HOST} ^www\.example\.co\.uk [NC]
RewriteRule ^short_url$ http://www.example.co.uk/folder/folder2/long_url [R=301,NC,L]
Hope this helps in the future.
Cheers