mod重写问题
我尝试使用此代码来隐藏 php 文件扩展名
,我有此网址 http://localhost/login/emprego.php 我想要 http://localhost/login/emprego ,
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
但
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L]
结果是文件的 url两种情况下的扩展。我已经重新启动了 apache 服务器,
请问是什么问题?
谢谢
i tried this code to hide the php file extension
i have this url http://localhost/login/emprego.php and i want http://localhost/login/emprego
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
and this
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L]
but the result is the url with the file extension in the two cases. I already restarted the apache server
what is the problem?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 httpd.conf 文件中的 mode_rewrite 是否为 On,因为此重写规则应该可以正常工作
Check if mode_rewrite is On in your httpd.conf file, because it this rewrite rules supposed to work just fine