Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
针对SEFs的Apache重写_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

针对SEFs的Apache重写

针对SEFs的Apache重写,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,如何让index.php处理请求 比如说 如果我在浏览器中键入SEFs http://localhost/friends http://localhost/me 改写为 http://localhost/index.php/friends http://localhost/index.php/me 这样我就可以通过$请求['PATH\u lNFO']访问朋友或我 我已经为apache中的根目录设置了mod rewrite on和allow all指令 需要一个.htaccess文件,在本文中

如何让index.php处理请求

比如说

如果我在浏览器中键入SEFs

http://localhost/friends
http://localhost/me
改写为

http://localhost/index.php/friends
http://localhost/index.php/me
这样我就可以通过$请求['PATH\u lNFO']访问朋友或我

我已经为apache中的根目录设置了mod rewrite on和allow all指令

需要一个.htaccess文件,

在本文中查找此重写规则^/?([a-zA-Z+)/([a-zA-Z+)/([a-zA-Z+)$display.php?国家=$1,州=$2,城市=$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>
AddDefaultCharset UTF-8
重新启动发动机
重写基/rtest
重写cond%{HTTP_HOST}^mathpdq\.com
重写规则^(.*)$http://www.mathpdq.com/rtest/$1[R=永久性,L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]

就这些

$\u请求['PATH\u INFO']
将设置为“
/friends
”或“
/me

(根据您的服务器配置,可能必须使用
原始路径信息
而不是
路径信息

RewriteRule ^friends$ index.php/friends [L]
RewriteRule ^me$ index.php/me [L]