Mode Rewrite; with/without trailing slash on end of url?

无人久伴 提交于 2019-11-28 07:03:39

The subpattern .[^/]* requires at least one arbitrary character. In your case it’s probably that trailing slash.

You should better stick to one writing (either with or without trailing slash) and redirect th wrong writing to the proper, like:

# remove trailing slash
RewriteRule ^(.*)/$ /$1 [L,R=301]

# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L,R=301]

plain old regexes:

RewriteRule ^signup/register/?$ /signup/register.php [NC]
...    
RewriteRule ^(url-rewrite)/?$ page.php [NC]
...

The ? after / specifies that there can be none or one / after your url-rewrite, as such it would accept it with or without the trailing /

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!