Skip to content

Instantly share code, notes, and snippets.

@bea-alec
Last active July 21, 2020 19:14
Show Gist options
  • Save bea-alec/e739ef41aaafac2a4ba8d2b800306512 to your computer and use it in GitHub Desktop.
Save bea-alec/e739ef41aaafac2a4ba8d2b800306512 to your computer and use it in GitHub Desktop.
mod_rewrite rules
# Drop URL parameters for paths do not need them
RewriteCond %{THE_REQUEST} \?
RewriteCond %{REQUEST_URI} !(^/help|/^admin|^archive) [NC]
RewriteCond %{QUERY_STRING} !itok=([0-9]+)
RewriteRule ^ %{REQUEST_URI} [L,R,QSD]
@cntlscrut
Copy link

I updated and tested this code and it looks to work locally. I was also able to stop it from reverting to /index.php for certain conditions.

# Drop URL parameters for paths do not need them
RewriteCond %{THE_REQUEST} !help?|archive?|admin?
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^?]*)\?
RewriteCond %{QUERY_STRING} !itok=([0-9]+)
RewriteRule (.*) /$1? [R=301,L]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment