Double Parameter URL Rewrite

会有一股神秘感。 提交于 2019-12-11 16:07:39

问题


I have the following URL with double parameters and for the first time would like to do double parameter rewrite.

My URL: http://localhost/b2b/post?post_id=1&post_subject=test

I'd like to rewrite it to: http://localhost/b2b/post/post_id/1/post_subject/test

My .htaccess is:

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>

回答1:


You should just write :

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]


来源:https://stackoverflow.com/questions/24457769/double-parameter-url-rewrite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!