Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
Php 双参数URL重写_Php_Url_Rewrite - Fatal编程技术网

Php 双参数URL重写

Php 双参数URL重写,php,url,rewrite,Php,Url,Rewrite,我有下面的URL与双参数和第一次想做双参数重写 我的网址:http://localhost/b2b/post?post_id=1&post_subject=test 我想把它改写成:http://localhost/b2b/post/post_id/1/post_subject/test 我的.htaccess是: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / R

我有下面的URL与双参数和第一次想做双参数重写

我的网址:http://localhost/b2b/post?post_id=1&post_subject=test

我想把它改写成:http://localhost/b2b/post/post_id/1/post_subject/test

我的.htaccess是:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_METHOD}  !=POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<Files ~ "^(.*)\.(inc|tpl|sql)$">
    Order deny,allow
    Deny from all
</Files>

你应该写:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^post/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)$  /post.php?$1=$2&$3=$4 [L]

很抱歉,只是没用。。。无论如何,谢谢你。。请帮助它可能是一个请求URI或需要的请求查询?您的.htaccess位于哪个文件夹中?本地主机?b2b?邮递重写是否对一个参数有效?在我看来,你的.htaccess是一团糟。您应该阅读本页: