Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess rewrite url remove subdirectory

Tags:

.htaccess

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.

like image 312
Sparkup Avatar asked Jul 22 '11 19:07

Sparkup


2 Answers

This is what I ended up doing :

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)folder 
RewriteRule ^(.*)$ folder/$1 [L]
like image 146
Sparkup Avatar answered Sep 28 '22 00:09

Sparkup


What about this?

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

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

like image 45
Tomas Avatar answered Sep 28 '22 01:09

Tomas