如何删除网站网址中的双斜线

时间:2017-03-17 12:00:11

标签: .htaccess url url-rewriting

我的网站网址也接受双斜线。例如,当我放https://www.jamalacademy.com/class/9th-class它接受然后我放 https://www.jamalacademy.com//class/9th-classhttps://www.jamalacademy.com///class/9th-class它也接受..即使我添加了这么多斜杠也接受了..

帮助我解决这个问题。 我目前的htaccess文件就像:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]

RedirectMatch 301 ^(.*)//+(.*)$ https://www.jamalacademy.com/$1/$2

RewriteEngine On
RewriteBase /
Options +FollowSymlinks

RewriteCond %{REQUEST_URI} //+
RewriteRule ^(.*) $1 [R=301,L]

RewriteEngine On
RewriteRule ^class/(.*)/?$ classes_list.php?get_page=$1 [NC,QSA] 
提前谢谢。

1 个答案:

答案 0 :(得分:0)

你可以像这样使用它:

RewriteEngine On

# remove multiple slashes from URLs
RewriteCond %{THE_REQUEST} //
RewriteRule ^.*$ /$0 [R=301,L,NE]    

RewriteRule ^class/(.*?)/?$ classes_list.php?get_page=$1 [NC,QSA,L]

确保在测试此更改之前清除浏览器缓存。