【发布时间】:2014-01-27 22:01:39
【问题描述】:
我有以下问题:
我的网站可通过两个域访问:
www.user.tucana.uberspace.de 和 www.my-domain.de
如何创建有效的 301 重定向 www.user.tucana.uberspace.de 到 www.my-domain.de ? 我的意思是,如果用户通过 www.user.tucana.uberspace.de/actual/news 进入我的网站,我希望我的 htaccess 将重定向到 www.my-domain.de/actual/news ...
在我的 htacces 中,我创建了以下代码:
选项 - 多视图 重写引擎开启
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteBase /
RewriteCond %{HTTP_HOST} !=www.my-domain.de
RewriteRule (.*) http://www.my-domain.de/$1 [R=301,L]
但问题是......如果用户在 www.user.tucana.uberspace.de/actual/news 进入该站点,他将被重定向到 www.my-domain.de/index.php/actual/news
此代码可以使用,但不适用于根 URL:
选项 - 多视图 重写引擎开启
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=www.my-domain.de [NC]
RewriteRule ^ http://www.my-domain.de%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
如果我使用上面的代码,网址 www.user.tucana.uberspace.de/actual/news 会更改为 www.my-domain.de/actual/news - 这是正确的, 但是,如果我输入 www.user.tucana.uberspace.de,URL 将更改为 www.my-domain.de/index.php ... 为什么 :-( ? 那么,如何避免 url 中的 index.php 呢?
【问题讨论】:
标签: apache .htaccess mod-rewrite laravel-4 http-status-code-301