如何从 PHP 中的 URL 中删除 index.php [英] How to Remove index.php from URL in PHP
本文介绍了如何从 PHP 中的 URL 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 url 中删除 index.php 但到目前为止我无法成功.我在本地服务器上使用 Wamp 服务器,在远程服务器上使用 Apache..在本地根目录中,我的项目文件位于像
I want to remove index.php from url but so far i couldn't succeed it. I'm using Wamp server on my local and Apache on remote server.. In local root directory, my project files are located in a subfolder like
www/project/index.php
我可以访问像
localhost/project/index.php/home
localhost/project/index.php/messages/?mId=3
我只想像访问它
localhost/project/home
localhost/project/messages/?mId=3
我已经尝试了一些 .htaccess 重写规则,但无法实现.
I already tried some .htaccess rewrite rule but couldnt make it.
推荐答案
以下是您需要的组织方式:
Here's how you need to organize:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
</ifModule>
然后您将拥有所需的一切.
And then you will have everything as you need.
这篇关于如何从 PHP 中的 URL 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文