Rule to rewrite folder, using part of the domain.
4 posts
• Page 1 of 1
Rule to rewrite folder, using part of the domain.
I am having trouble putting this rule together:
I need to match part of the domain and redirect specific folders to another domain using the captured part.
Ideally it should also work if the www is not specified, but that's not essential.
eg.
www.mysite.com/a/ --> media.mysite.com/x/a
mysite.com/a/ --> media.mysite.com/x/a
The catch is I don't want to put the domain into the rule, (eg. the "mysite" part) as it has to match for any site on the server. However they are all .com domains.
Any help appreciated!
Thanks
I need to match part of the domain and redirect specific folders to another domain using the captured part.
Ideally it should also work if the www is not specified, but that's not essential.
eg.
www.mysite.com/a/ --> media.mysite.com/x/a
mysite.com/a/ --> media.mysite.com/x/a
The catch is I don't want to put the domain into the rule, (eg. the "mysite" part) as it has to match for any site on the server. However they are all .com domains.
Any help appreciated!
Thanks
Re: Rule to rewrite folder, using part of the domain.
Hello.
Sorry, it is unclear from your explanation where exactly you need to match a domain and how to redirect it.
From your example it seems like you need to redirect everything in folder /a/ (where? in mysite.com or on any site?) to media.mysite.com/x/a*
Sorry, it is unclear from your explanation where exactly you need to match a domain and how to redirect it.
From your example it seems like you need to redirect everything in folder /a/ (where? in mysite.com or on any site?) to media.mysite.com/x/a*
Re: Rule to rewrite folder, using part of the domain.
Sorry I was unclear.
I want to rewrite everything in the /a folder in www.mysite.com to the same path in media.mysite.com but with a /x/ at the start of the path. It should happen for all sites.
eg.
www.mysite.com/a/1234/567/89.jpg --> media.mysite.com/x/a/1234/567/89.jpg
www.mysecondsite.com/a/1234/567/89.jpg --> media.mysecondsite.com/x/a/1234/567/89.jpg
Thank you.
I want to rewrite everything in the /a folder in www.mysite.com to the same path in media.mysite.com but with a /x/ at the start of the path. It should happen for all sites.
eg.
www.mysite.com/a/1234/567/89.jpg --> media.mysite.com/x/a/1234/567/89.jpg
www.mysecondsite.com/a/1234/567/89.jpg --> media.mysecondsite.com/x/a/1234/567/89.jpg
Thank you.
Re: Rule to rewrite folder, using part of the domain.
I suppose you actually need a redirect, not rewrite. Please try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} (?:www\.)?mysite\.com [NC]
RewriteRule (/a.*) http\://media.mysite.com/x$1 [NC, QSA, R]
RewriteEngine On
RewriteCond %{HTTP_HOST} (?:www\.)?mysite\.com [NC]
RewriteRule (/a.*) http\://media.mysite.com/x$1 [NC, QSA, R]
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 29 guests