0

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:

www.example.com/subfolder/*

I would like the url to be:

www.example.com/*

thanks

3 Answers 3

7

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.

Sign up to request clarification or add additional context in comments.

Comments

2

try

RewriteRule (.*) /subfolder/$1 [L]

1 Comment

oh, @Gumbo solutions are better!
0

You need to capture the .* like this:

RewriteRule ^(.*)/$ /$1/subfolder/ [L]

2 Comments

"subfolder" should come before "$1".
(.*) eats all avaiable characters, so no need to ^, i think

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.