Sparkup
Sparkup

Reputation: 3754

htaccess rewrite url remove subdirectory

I'm trying to rewrite

http://www.example.com/directory/folder/*

to

http://www.example.com/directory/*

the htaccess file is in directory

this is my .htaccess file :

RewriteEngine on
RewriteBase /directory/
RewriteRule ^(.*)$ folder/$1 [L]

Any help would be much appreciated.

Upvotes: 18

Views: 32167

Answers (2)

Tomas
Tomas

Reputation: 59495

What about this?

RewriteEngine on
RewriteRule ^folder/(.*) /directory/$1 [L]

Or you can go without [L] or use [R] instead.

Upvotes: 5

Sparkup
Sparkup

Reputation: 3754

This is what I ended up doing :

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)folder 
RewriteRule ^(.*)$ folder/$1 [L]

Upvotes: 21

Related Questions