htaccess redirect alias to main domain

丶灬走出姿态 提交于 2019-12-24 01:19:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!