I would like to remove the query string from the URL and rewrite it without the query string without having to re-code the link structure.
I have added this:
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [R,L]
to the end of my existing .htaccss code (so that it is the last thing that is done, since there are other re-write rules before this) but the query string is not removed. What am I doing wrong?
This is the content of my current .htaccess file:
RewriteEngine On
RewriteRule ^userfiles/ - [L]
RewriteRule ^userdata/ - [L]
RewriteCond %{THE_REQUEST} /index.php?p=(?!admin)(?!superadmin)((?![^&]*?edit)[^s&]+) [NC]
RewriteCond %{THE_REQUEST} /index.php?p=([^s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?p=$1 [L,QSA]
Also I have a general question about how that affects the availability of query strings as variables... in other words if I re-write the URL to NOT show the query strings, is that query string still available if in PHP I write $_GET['q'] or will it then be not set anymore?
Thanks
question from:
https://stackoverflow.com/questions/65866501/rewrite-query-string-with-htaccess-without-altering-link-structure 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…