使用htaccess从URL中删除目录名称

时间:2015-05-31 13:47:01

标签: .htaccess

我的网址是打击:

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

我想删除" user_videos"来自网址和网址应如下所示: http://www.example.com/rakesh/index.php

请帮助我:

我正在编写下面的代码,但它不起作用:

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

3 个答案:

答案 0 :(得分:1)

尝试这个

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

答案 1 :(得分:0)

尝试:

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

答案 2 :(得分:0)

将此规则放在 /joi-videos/.htaccess

RewriteEngine On
RewriteBase /joi-videos/

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