mod_rewrite .htaccess 文件

发布于 2024-10-10 10:23:45 字数 169 浏览 0 评论 0原文

由于某些奇怪的原因,这在本地主机上有效,但在远程服务器上不起作用

——从所有 php 文件中删除 .php 扩展名

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

For some weird reason this works on localhost but doesn't work on remote server

---to remove .php extension from ALL php files

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

格子衫的從容 2024-10-17 10:23:45

您需要确保 mod_rewrite 已启用。 完成此操作。

LoadModule rewrite_module modules/mod_rewrite.so

.htaccess 顶部来

RewriteEngine On

您可以通过将 并将其添加到httpd.conf 文件中的

You need to make sure mod_rewrite is enabled. You do this by putting

LoadModule rewrite_module modules/mod_rewrite.so

And adding this to top of .htaccess

RewriteEngine On

in you httpd.conf file.

情何以堪。 2024-10-17 10:23:45

还要确保如果在远程服务器上的子目录中访问您的代码,则在 .htaccess 中设置正确的 RewriteBase

also ensure that if your code is accessed in a subdirectory on the remote server, you set the correct RewriteBase in your .htaccess

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文