【问题标题】:htaccess redirect alias to main domainhtaccess 将别名重定向到主域
【发布时间】:2013-11-09 13:08:58
【问题描述】:

我正在尝试将每个可能的 url 从别名域重定向到主域。我正在使用 htaccess 使我的网址更漂亮。这是我到目前为止的示例和代码:

期望的输出:

Alias page: www.stavimedumsvepomoci.cz/forum.html
gets redirected to the main domain: www.stavbadomusvepomoci.cz/forum.html

现在我需要它来处理 .cz/ 之后的每个可能的网址

到目前为止,我有这个:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?stavimedumsvepomoci\.cz [NC]
RewriteRule ^(.*)$ http://stavbadomusvepomoci.cz/$1 [R,L]

这基本上将任何页面从别名重定向到主域首页。 如何从 alias/every/possible/url 重定向到 maindomain/every/possible/url。

感谢您的回答!

【问题讨论】:

  • 你已经这样做了:$1 允许这样做,别名/every/possible/url 到 maindomain/every/possible/url。你测试过吗?
  • 好吧,我会被诅咒的,..当我尝试它时它不起作用,现在它正在工作,..谢谢:D

标签: php apache .htaccess mod-rewrite redirect


【解决方案1】:

就像在 cmets 中一样,您已经这样做了:$1 允许这样做,别名/every/possible/url 到 maindomain/every/possible/url。你测试过吗?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?stavimedumsvepomoci\.cz [NC]
RewriteRule ^(.*)$ http://stavbadomusvepomoci.cz/$1 [R,L]

希望你成功。

[添加]

你可能已经这样做了:

/etc/init.d/apache2 restart

【讨论】:

  • 如上所述,.. 非常感谢。不知道为什么它不起作用。我很高兴现在..
猜你喜欢
  • 1970-01-01
  • 2011-08-19
  • 1970-01-01
  • 2017-12-26
  • 2017-04-11
  • 2011-02-12
  • 2013-06-16
  • 1970-01-01
  • 2011-01-30
相关资源
最近更新 更多