【发布时间】:2021-09-25 02:34:02
【问题描述】:
这是我的 .htacess,我可以删除 .php 扩展名,但它没有按照预期的输出工作(例如 https://localhost/shap/example.php 到 https://localhost/shap/example ) 它适用于 index.php 但它适用于其他 .php 页面,它被卡在重定向中 请帮我解决这个问题
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# Return 404 if original request is .php
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
# RewriteRule .* - [L,R=404]
RewriteRule ^index\.php$ https://localhost/shap/ [NC,R]
RewriteRule ^example\.php$ https://localhost/shap/example[R]
</IfModule>
【问题讨论】:
-
如果您在浏览器中点击链接
https://localhost/example/example.php,能否告诉我们? -
这是@RavinderSingh13的实际图像
-
您正在点击链接
https://localhost/shap/example应该由后端的https://localhost/shap/example.php链接提供服务?请确认一次。 -
它是 eample.php 仅在后端,但是当我把这个 RewriteRule ^example\.php$ localhost/shap/example[R] 放在 htaccess 中删除它显示的上述错误。 @RavinderSingh13
-
所以你在浏览器中点击
https://localhost/example/example.php?
标签: .htaccess redirect mod-rewrite url-rewriting friendly-url