mod_rewrite .htaccess 文件
由于某些奇怪的原因,这在本地主机上有效,但在远程服务器上不起作用
——从所有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要确保 mod_rewrite 已启用。 完成此操作。
.htaccess 顶部来
您可以通过将 并将其添加到httpd.conf 文件中的
You need to make sure mod_rewrite is enabled. You do this by putting
And adding this to top of .htaccess
in you httpd.conf file.
还要确保如果在远程服务器上的子目录中访问您的代码,则在 .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