Removing a folder from the URL using Apache mod_rewrite


How do you remove a folder from the URL?
I have a Drupal installation in a folder and I would like to remove that subfolder from the URL.

So instead of:*

I would like the url to be:*


Best Solution

Try this:

RewriteRule !^subfolder/ subfolder%{REQUEST_URI} [L]

And to redirect direct requests of /subfolder/…:

RewriteCond %{THE_REQUEST} ^GET\ /subfolder/
RewriteRule ^subfolder/(.*) /$1 [L,R=301]

Or, even better, change your document root to that subfolder.

Related Question