我希望我的 URL 添加尾部斜杠,但前提是 URL 不以锚结尾。
这是我当前的 .htaccess 文件
# ----------------------------------------------------------------------
# Enable Rewrite Engine
# ----------------------------------------------------------------------
RewriteEngine On
RewriteBase /
# ----------------------------------------------------------------------
# Remove the www from the URL
# ----------------------------------------------------------------------
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# ----------------------------------------------------------------------
# Add a trailing slash to paths without an extension
# ----------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# ----------------------------------------------------------------------
# Remove index.php
# ----------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
当我链接到锚定部分时,URL 会被写入:
http://mysite.com/subdir/#anchor
当它们看起来像这样时:
http://mysite.com/subdir#anchor
常规 URL 应如下所示:
http://mysite.com/directory/sub/
我很困惑,所以任何帮助都会很棒!
干杯,
丹