Rakesh K
Rakesh K

Reputation: 712

Remove a directory name from URL using htaccess

I am having URL as blow:

http://www.example.com/joi-videos/user_videos/rakesh/index.php

I want to remove "user_videos" from url and URL should be like like below: http://www.example.com/rakesh/index.php

Please help me with this:

I am writing below code but its not working:

RewriteEngine On
RewriteRule ^user_videos/(.*)$ /$1 [L]

Upvotes: 2

Views: 50

Answers (3)

anubhava
anubhava

Reputation: 786091

Place this rule inside /joi-videos/.htaccess:

RewriteEngine On
RewriteBase /joi-videos/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!user_videos/).*)$ user_videos/$1 [NC,L]

Upvotes: 0

Hilal Pcnador
Hilal Pcnador

Reputation: 53

try this one

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/?$ user_videos/$1 [QSA,L]

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41249

Try :

RewriteEngine On
RewriteRule ^joi-videos/(.*)/?$ /joi-videos/user_videos/rakesh/index.php [L,NC]

Upvotes: 0

Related Questions