/ (directory/?param=value)
cannot change this url
directory/?param=value
to
directory/value
It's not work:
RewriteCond %{REQUEST_URI} ^/directory/.*
RewriteRule ^/directory/\?param=(.*) /directory/$1 [L]
My problem is how to replace ?param= ???
These rules should work for you:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(directory)/\?param=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L]
RewriteRule ^(directory)/([^/]+)/?$ /$1/?param=$2 [L,QSA,NC]
You can't match against the query string (everything after the ?
) in a RewriteRule
, try:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?directory/(.+)$ /directory/?param=$1 [L]
That takes: directory/value and rewrites it internally to serve the content at directory/?param=value .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.