如何让 index.php 处理请求
例如
如果我在浏览器中输入 SEF
http://localhost/friends
http://localhost/me
重写为
http://localhost/index.php/friends
http://localhost/index.php/me
所以我可以从 $_REQUEST['PATH_lNFO'] 访问朋友或我
我已经修改并允许为 apache 中的根目录设置所有指令。
需要一个 .htaccess 文件,
如何让 index.php 处理请求
例如
如果我在浏览器中输入 SEF
http://localhost/friends
http://localhost/me
重写为
http://localhost/index.php/friends
http://localhost/index.php/me
所以我可以从 $_REQUEST['PATH_lNFO'] 访问朋友或我
我已经修改并允许为 apache 中的根目录设置所有指令。
需要一个 .htaccess 文件,
在这篇文章 http://www.sitepoint.com/apache-mod_rewrite-examples/ 中查看这个 RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)/([ a-zA-Z_]+)$ display.php?country=$1&state=$2&city=$3 [L]
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rtest
RewriteCond %{HTTP_HOST} ^mathpdq\.com
RewriteRule ^(.*)$ http://www.mathpdq.com/rtest/$1 [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
RewriteRule ^friends$ index.php/friends [L]
RewriteRule ^me$ index.php/me [L]
就这样。
$_REQUEST['PATH_INFO']将设置为“ /friends”或“ /me”。
(根据您的服务器配置ORIG_PATH_INFO,可能必须使用而不是PATH_INFO)