【发布时间】:2012-06-20 20:20:43
【问题描述】:
我希望我的网址添加尾部斜杠,但前提是网址不以锚结尾。
这是我当前的 .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/
我很困惑,所以任何帮助都会很棒!
干杯,
丹
【问题讨论】:
标签: apache .htaccess mod-rewrite expressionengine