Skip to content

Instantly share code, notes, and snippets.

@ahoNerd
Last active November 12, 2022 17:06
Show Gist options
  • Save ahoNerd/06bc08be0087df0104875d02c7a8b69e to your computer and use it in GitHub Desktop.
Save ahoNerd/06bc08be0087df0104875d02c7a8b69e to your computer and use it in GitHub Desktop.
Clean URL, read more at https://ahonerd.com/htaccess
RewriteRule ^en$ /?&%{QUERY_STRING}
RewriteRule ^jp$ /?&%{QUERY_STRING}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L]
RewriteRule ^en/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ /index.php?page=$1&sub=$2 [L,NC,QSA]
RewriteRule ^en/([a-zA-Z0-9-]+)$ /index.php?page=$1 [L,NC,QSA]
RewriteRule ^jp/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ /index.php?page=$1&sub=$2 [L,NC,QSA]
RewriteRule ^jp/([a-zA-Z0-9-]+)$ /index.php?page=$1 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ /index.php?page=$1&sub=$2 [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-]+)$ /index.php?page=$1 [L,NC,QSA]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment