删除尾随斜线的子目录的URL索引 [英] Removing trailing slash for sub directory url indexing

查看:212
本文介绍了删除尾随斜线的子目录的URL索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

example.com/contact.php  <- I want to like this -> example.com/contact

和此也想...

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

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

i want to like this.. plz help me for this one

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

if have real directory want to go there...

编辑:

example.com/watch.php?id=1995/english-videos 这个环节是不行的..我想重定向这样的 example.com/contact 不想斜线。我想工作这个链接 example.com/watch.php?id=1995/english-videos

example.com/watch.php?id=1995/english-videos this link is not work.. and i want to redirect like this example.com/contact dont want slash. and i want to work this link example.com/watch.php?id=1995/english-videos

/的.htaccess

/.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 /联系方式 example.com/about ,但这个环节要像

example.com/watch.php?id=1995/english-videos not work :( other link i want like this example.com/contact , example.com/about but this link want like that

推荐答案

您完整的.htaccess可以是这样的:

Your complete .htaccess can be like that:

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]

这篇关于删除尾随斜线的子目录的URL索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆