问题
i am trying to redirect from alias domain to main domain for every possible url. I am using htaccess to make my urls more beautiful. This is my example and code I have so far:
Desired outpout:
Alias page: www.stavimedumsvepomoci.cz/forum.html
gets redirected to the main domain: www.stavbadomusvepomoci.cz/forum.html
Now I need this to work for every possible url I can have after the .cz/
So far I have this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?stavimedumsvepomoci\.cz [NC]
RewriteRule ^(.*)$ http://stavbadomusvepomoci.cz/$1 [R,L]
Which basically redirects any page from the alias to the main domain front page. How can I redirect from alias/every/possible/url to maindomain/every/possible/url.
Thanks for your answers!
回答1:
As in the comments, You do already this: $1 permits to do it, alias/every/possible/url to maindomain/every/possible/url. Have you tested it?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?stavimedumsvepomoci\.cz [NC]
RewriteRule ^(.*)$ http://stavbadomusvepomoci.cz/$1 [R,L]
Hope you succeed.
[ADDED]
You might have done:
/etc/init.d/apache2 restart
来源:https://stackoverflow.com/questions/19876329/htaccess-redirect-alias-to-main-domain