重写 url 在 htaccess 中不起作用
Rewrite url not working in htaccess
我有网站。我只想使用 .htaccess
重写 url
这是我要重写的代码:
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_data.php?keywords=one+piece&f=149
我想把这个转换成这个
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=&f= [QSA,L,NC]
我有网站。我只想使用 .htaccess
重写 url
这是我要重写的代码:
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_data.php?keywords=one+piece&f=149
我想把这个转换成这个
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=&f= [QSA,L,NC]