2014-04-12 64 views
1
example.com/contact.php <- I want to like this -> example.com/contact 

,这也想...删除尾随斜线的子目录的URL索引

example.com/contact/ (havent real directory. want to redirect /contact) 
example.com/contact.(any extension redirect to /contact) 

我想这样的.. plz帮助我,这一个

如果有真正想要的目录去那里......

编辑:

example.com/watch.php?id=1995/english-videos这个环节是不行的..我想与r像这样的转接example.com/contact不想要斜线。我想工作这个环节example.com/watch.php?id=1995/english-videos

/.htaccess

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^col3negmovie.com$ 
RewriteRule ^(.*)$ "http\:\/\/www\.col3negmovie\.com\/$1" [R=301,L] 


Options +FollowSymLinks -MultiViews 
RewriteEngine on 
RewriteBase/

RewriteCond %{HTTP_HOST} ^col3negmovie\.com$ 
RewriteRule ^(.*)$ http://www.col3negmovie.com/$1 [R=301,L] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+watchnew1\.php\?id=([^\s&]+) [NC] 
RewriteRule^watch/%1? [R=301,L] 

RewriteRule ^watch/(.+?)/?$ watchnew1.php?id=$1 [L,QSA,NC] 

# remove trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s] 
RewriteRule ^(.+?)/$ /$1 [R=301,L] 

# remove .php extension 
RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] 
RewriteRule^/%1 [R=301,L,NE] 

# add .php extension internally 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] 
RewriteRule ^(.+?)/?$ /$1.php [L] 

example.com/watch.php?id=1995/english-videos不工作:(其他链接,我想这样的example.com/contactexample.com/about但这个环节要像

+0

为什么你想从实际目录中删除尾部斜杠?这是很大的安全性r isk如果该目录没有默认的'index.php'。 – anubhava

+0

哎呀!为什么?什么问题?你能否描述我 – user3501407

+0

我已经写过这个风险的原因。 – anubhava

回答

1

你完整的.htaccess可以这样:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 
RewriteBase/

RewriteCond %{HTTP_HOST} ^col3negmovie\.com$ [NC] 
RewriteRule^http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 

RewriteCond %{THE_REQUEST} \s/+watchnew1\.php\?id=([^\s&]+) [NC] 
RewriteRule^watch/%1? [R=301,L] 

# remove trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s] 
RewriteRule ^(.+?)/$ $1 [R=301,L] 

# remove .php extension 
RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] 
RewriteRule^%1 [R=301,L,NE] 

RewriteRule ^watch/(.+?)/?$ watchnew1.php?id=$1 [L,QSA,NC] 

# add .php extension internally 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] 
RewriteRule ^(.+?)/?$ $1.php [L] 
+0

最后一个#的意思是什么#在内部添加.php扩展 – user3501407

+0

先测试它,看看它是否工作。 – anubhava

+0

工作,但它的重定向到这样/联系/但我想/联系像这样 – user3501407