【发布时间】:2017-08-13 03:08:55
【问题描述】:
我必须从
重定向 (301)http://domain/index.php 到 http://domain/
我已经按照以下规则完成了:
RewriteCond %{THE_REQUEST} ^.*/index.php
重写规则 ^(.*)index.php$ /$1 [R=301,L]
好的。它有效,但我不想允许从以下网址重定向:
http://domain/asd/index.php
我试图改变条件:
RewriteCond %{THE_REQUEST} ^/index.php
RewriteCond %{THE_REQUEST} ^/index.php
但没有成功。
那么,如何仅从http://domain/index.php 重定向到http://domain/
ps:我不想使用 REDIRECT 命令
【问题讨论】:
-
RewriteCond %{THE_REQUEST} ^/index.php
-
你为什么不简单地使用 apache 的
DirectoryIndex指令呢? httpd.apache.org/docs/2.4/mod/mod_dir.html -
Unamata Sanatarai - 就像我写的那样,它不起作用
-
arkascha - 我不知道,谢谢!
标签: .htaccess mod-rewrite