【问题标题】:.htaccess redirecting index.php to root for main domain.htaccess 将 index.php 重定向到主域的根目录
【发布时间】:2016-11-22 00:34:57
【问题描述】:

我只想将我的域 index.php 文件重定向到网站的根目录,如下所示:

www.domain.com/index.phpwww.domain.com

但不适用于我的子域,比如这个:

shop.domain.com/index.php.

这是我的代码:

#Rewrite non www to www, except subdomains
RewriteCond %{HTTP_HOST} !^shop.domain.com$
RewriteCond %{HTTP_HOST} !^sub.domain.com$
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]

#Rewrite index.php to root
RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

请帮忙..提前谢谢..

【问题讨论】:

  • 在 VirtualHost 部分中使用 RewriteCond

标签: apache .htaccess redirect url-rewriting


【解决方案1】:

我在 cPanel 中更改了所有重定向链接,其中一些在 .htaccess 中。

【讨论】:

    猜你喜欢
    • 2012-04-27
    • 2014-05-14
    • 2017-01-12
    • 2013-03-06
    • 2017-06-26
    • 1970-01-01
    • 2013-04-10
    • 2014-01-07
    • 2016-01-21
    相关资源
    最近更新 更多