Skip to content

Instantly share code, notes, and snippets.

@jvanja
Last active June 15, 2020 09:22
Show Gist options
  • Save jvanja/3975925 to your computer and use it in GitHub Desktop.
Save jvanja/3975925 to your computer and use it in GitHub Desktop.
Rewrite rule for .htaccess for rewritting /page/subpage to ?page=page&subpage=subpage
# redirects for url params
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)$ index.php?page=$1&subpage=$2
RewriteRule ^([a-zA-Z0-9-z\-\_]+)/([a-zA-Z0-9-z\-\_]+)/$ index.php?page=$1&subpage=$2
# index file priority
DirectoryIndex index.html index.htm index.php welcome.html
# forbid file listing for root and subdirectories
Options All -Indexes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment