重写url无法在htaccess中工作
问题描述:
我有网站。我只是想用.htaccess
这里是我想重写代码重写网址:重写url无法在htaccess中工作
RewriteEngine On
RewriteBase/
RewriteCond %{QUERY_STRING} /search_data.php\?keywords=([^&]+)&f=([^\s&]+) [NC]
RewriteRule ^/search_data.php/?$ /search/%1/%2? [R=301,L,NC]
这个当前的URL
我想将其转换为这个
http://localhost/mywbsite/search/one-piece/149
我试过上面的代码,但它不工作请帮我
答
QUERY_STRING
仅用于匹配没有URI的查询字符串。
您需要使用:
Options -MultiViews
RewriteEngine On
RewriteBase /mywbsite/
RewriteCond %{THE_REQUEST} /search_data\.php\?keywords=([^&]+)&f=([^\s&]+) [NC]
RewriteRule^search/%1/%2? [R=301,L]
RewriteRule ^search/([^/]+)/([^/]+)/?$ search_data.php?keywords=$1&f=$2 [QSA,L,NC]
哎嗨的工作,但问题是它的也是这个代码我的网址后也从网址中删除我的文件夹名称为http://本地主机/搜索/一个+件/ 149 –
我的意思是在你的htaccess代码后,我的新网址是localhost/search/one + piece/149,而且我想要这样的http:// localhost/mywbsite/search/one-piece/149上面的代码去除mywbsite,即我的项目名称 –
泰克斯它为我工作我不能给你1我没有足够的声誉索里 –