Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache 重定向+;重写无限循环_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache 重定向+;重写无限循环

Apache 重定向+;重写无限循环,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,对不起,我的英语不是很好,但我会尽力解释我的问题。 所以。”php'是我的主登录页 A.每个请求都应该转到index.php。 这很简单。RewriteRule.*index.php[L](简化)。 因此,当我在addr bar中编写'News/123'时,index.php将处理它并向我显示新闻。它很好用 B.但我还需要将addr bar中输入的'/index.php'替换为'/Home',然后->A.我认为可以通过Redirect/index.php/Main实现,但这会导致无限重定向循环

对不起,我的英语不是很好,但我会尽力解释我的问题。
所以。”php'是我的主登录页

A.每个请求都应该转到index.php。 这很简单。
RewriteRule.*index.php[L]
(简化)。 因此,当我在addr bar中编写'News/123'时,index.php将处理它并向我显示新闻。它很好用

B.但我还需要将addr bar中输入的'/index.php'替换为'/Home',然后->A.我认为可以通过
Redirect/index.php/Main
实现,但这会导致无限重定向循环


有人能帮我吗?

您可以在root.htaccess中使用这些规则:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php$ /home [L,R=302]

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php [L]

非常感谢。它起作用了。据我所知,这里利润的关键是R=302,它通过重定向来改变地址?是的,这是正确的,
%{THE_REQUEST}
是Apache收到的原始请求。