我有这个工作代码,
RewriteEngine On
RewriteBase /
DirectorySlash Off
RewriteRule ^(.*)\/$ /page.php?page=$1 [L]
RewriteRule ^news/(.*)\/$ /news/article.php?id=$1 [L]
我想删除URL末尾的 / ;这会给出这样的结果(请参阅最后两行的更改):
RewriteEngine On
RewriteBase /
DirectorySlash Off
RewriteRule ^(.*)\$ /page.php?page=$1 [L]
RewriteRule ^news/(.*)\$ /news/article.php?id=$1 [L]
但是,如果我在尝试访问文件时以这种方式保留它,例如,www.domain.com/register
而不是www.domain.com/register/
,它会抛出错误 404。