重定向+重写无限循环

Redirect + rewrite infinite loop

对不起,我的英语不是很好,但我会尽力解释我的问题。
所以。 'index.php' 是我的主要着陆页。

一个。每个请求都应该发送到 index.php。 很简单。RewriteRule .* index.php [L](简化)。 因此,当我在地址栏中写入 'News/123' 时,index.php 将处理它并向我显示新闻。它工作正常。

乙。但我还需要将地址栏中输入的'/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]