Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess将index.php重定向到其他重写规则,导致循环,即使带有[L]标志_.htaccess_Url Rewriting - Fatal编程技术网

.htaccess将index.php重定向到其他重写规则,导致循环,即使带有[L]标志

.htaccess将index.php重定向到其他重写规则,导致循环,即使带有[L]标志,.htaccess,url-rewriting,.htaccess,Url Rewriting,所以我有这个。htaccess: RewriteEngine On RewriteBase / RewriteRule ^home$ /index.php [L] RewriteRule ^edit$ /edit.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ /new.ph

所以我有这个。htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^home$ /index.php [L]
RewriteRule ^edit$ /edit.php [L]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /new.php
它会将任何未知url重定向到
/new.php

并且只将保留的
/home
/edit
重定向到相应的页面

但我还想将任何人重定向到根
/
/index.php | html
以转到
/home
所以我试着用这个:

RewriteRule ^index\.(php|html?)$ /home [R=301,L]
但它会导致一个循环,这是可以理解的

它还会导致自身的环回,从而中断my
/home
重定向。 如何使
/
/index.php
重定向到
/index.php
,但仍在其后面添加
/home


我还尝试删除了每一行RewriteCond,但没有任何好处。

也许你可以将index.php重命名为home.php,这似乎是避免循环的最简单方法。

我喜欢你的想法,但仍然存在一个问题,当人们填写/home.php时,它会显示在URL中,我想隐藏所有可能的.php或其他文件引用…@TrySpace只需将其更改为人们永远猜不到的
主页文件名。还请注意,edit.php和new.php.Yeah也有同样的问题,但我仍然想知道,在这种情况下,是否可以忽略几乎所有的文件请求,并将它们重定向/重写到/home或/new或/edit。这不可能吗?