apache - 如何通过 .htaccess 正确地将 index.php 重定向到另一个页面?

标签 apache .htaccess mod-rewrite redirect indexing

目前我的 htaccess 文件包含此规则,将 website.org/index.php 重定向到 website.org/en/home

RewriteRule index.php /en/home [R=301]

不过,目前还有其他index.php更深层文件夹中的页面重定向!例如website.org/folder/index.php重定向到 website.org/en/home
我怎样才能让该规则仅适用于根目录,而不适用于更深的文件夹?
非常感谢。

最佳答案

RewriteRule ^index.php /en/home [R=301]

关于apache - 如何通过 .htaccess 正确地将 index.php 重定向到另一个页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5205881/

相关文章:

php - 使用 mod_rewrite 将路径转换为查询字符串变量

html - 控制缓存过期

regex - 使用 HTACCESS 将页面重定向到其中包含问号的 URL?

apache - 如何将特定链接重定向到 https ://everything else to http://using . htaccess?

php - apache 服务 php exec 不工作

java - 我怎么知道 tomcat 是否在 Apache 后面运行?

php - 将 Solr 与 PHP 结合使用

javascript - 使跟踪代码从 URL 栏中消失

php - 目标 URL 上未收到发布数据

docker - 将 mod_rewrite 添加到 Docker 镜像 httpd :alpine