Skip to content

Instantly share code, notes, and snippets.

@kabilashgit
Last active April 17, 2019 07:41
Show Gist options
  • Save kabilashgit/b46acefb5e816dd4af8a45a6c32c367d to your computer and use it in GitHub Desktop.
Save kabilashgit/b46acefb5e816dd4af8a45a6c32c367d to your computer and use it in GitHub Desktop.
Url rewriting for hiding folder name and open it without folder name

eg: http://example.com/foldername (to) http://example.com

Keep this rule in root .htaccess:

RewriteEngine On

RewriteRule ^(?!foldername/)(.*)$ foldername/$1 [L,NC]

Then have this simplified code in /fodlername/.htaccess:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment