【发布时间】:2021-12-20 02:12:25
【问题描述】:
我目前在.htaccess 文件中有以下内容来重写.php 扩展:
# /var/www/html/help/.htaccess
# To externally redirect /dir/foo.php to /dir/foo excluding POST requests
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=302,L,NE]
# To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
按预期工作。但是我希望添加一些额外的重写,例如将/help/open 重定向到/help/submit。我尝试的一切似乎都以来自 /help/open -> /help/submit 并返回的无限重定向结束。
RewriteRule open.php /help/submit [R=302,NE,L]
RewriteRule submit /help/open.php [L]
有人可以建议我如何在此处实现额外的 URL 重写而不导致无限循环吗?
【问题讨论】:
标签: php .htaccess mod-rewrite url-rewriting apache2