捕获index.php htaccess之后/不之后的第一个单词
我想在不是以html index.php开头的单词后面添加/slash 例如:捕获index.php htaccess之后/不之后的第一个单词,php,apache,.htaccess,http-status-code-301,Php,Apache,.htaccess,Http Status Code 301,我想在不是以html index.php开头的单词后面添加/slash 例如: www.domain.com/test ---> www.domain.com/test/ www.domain.com/index.php?test --> Not change www.domain.com/test/test --> Notchange 我知道如何使用htaccess添加斜杠,但我不知道如何不在url的index.php开头的末尾添加斜杠,或者不使用两个/(url类似于
www.domain.com/test ---> www.domain.com/test/
www.domain.com/index.php?test --> Not change
www.domain.com/test/test --> Notchange
我知道如何使用htaccess添加斜杠,但我不知道如何不在url的index.php开头的末尾添加斜杠,或者不使用两个/(url类似于domain.com/test/test)您可以使用以下规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.(html|php)$ [NC]
RewriteRule ^[^/]+/?$ %{REQUEST_URI}/ [L,R=301]
我的访问权限: