删除尾随斜线的子目录的URL索引斜线、子目录、索引、URL

2023-09-02 00:37:14 作者:我的同桌是沙雕

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]
 
精彩推荐
图片推荐