Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

URL rewriting

View gist:874000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Why rewrite URLs? Read this:
# Apache (.htaccess or httpd.conf)
# Make sure AllowOverride is on for the directory, or put the rewrite rules in httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
# Nginx (nginx.conf)
try_files $uri /index.php;
# More reading:
Note: Thanks to James ( for his improvements and fixes (

#Lighttpd Rewrite
url.rewrite-once = ( "/(.*)" => "/index.php/$1" )

Using XAMPP for development, I was getting thrown to its splash page any time I attempted to add params to my URL. Removing the leading slash in front of index.php in the RewriteRule resolved this. Modified rule follows.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L] 

Note: This is while using XAMPP in development using klein.php to route in an application that was not in the DocumentRoot. See Gist: for help with dispatching in this scenario.

For me the following was the best solution (I'm developing with xampp):

RewriteEngine On
# The base is the base directory (of the project)
RewriteBase /sites/
# The request is only handled if it isn't sent to a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# The requests are rewritten (case insensitive and last)
RewriteRule ^(.*)$ default.php [NC,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.