Sometimes I find that URLs on my website show up with mywebsite_smf_smf1_session=
.
For example:
http://mywebsite.com/index.php?mywebsite_smf_smf1_session=6goevo28vf18ubqgb5uh6r08b2&topic=332242.msg916981
http://mywebsite.com/index.php?mywebsite_smf_smf1_session=6gqvo88lu5fnl1qmj7temt0113&topic=316196.msg931242
The part that contains mywebsite_smf_smf1_session=###
shouldn't be in the URL, but the link still redirects to the correct page.
I would like to know how I can use mod_rewrite in .htaccess so that when someone clicks a URL containing mywebsite_smf_smf1_session=###&
, it automatically reverts to the version not containing it:
Clicking:
http:// mywebsite.com/index.php?mywebsite_smf_smf1_session=6gqvo88lu5fnl1qmj7temt0113&topic=316196.msg931242
Becomes:
http:// mywebsite.com/index.php?topic=316196.msg931242
You can use this rule in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^mywebsite_smf_smf1_session=[^&]*(?:&(.*))?$ [NC]
RewriteRule ^index\.php$ %{REQUEST_URI}?%1 [NE,L,NC,R=302]
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.