我想从我的Apache 42年3月1日子目录文件夹删除尾随斜线但是DirectorySlash关不支持我的版本的Apache的命令时,我尝试将规则添加到我的.htaccess文件。
I’m trying to remove the trailing slash from my sub-directory folders in Apache 1.3.42 however the command DirectorySlash Off is not supported in my version of Apache when I try to add the rule to my .htaccess file.
目前我的联系表现为这样:
Currently my links behave as so:
www.domain.com/folder定向到www.domain.com/folder~~V /
www.domain.com/folder directs to www.domain.com/folder/
我要的是:
www.domain.com/folder/直接到www.domain.com/folder~~V
www.domain.com/folder/ to direct to www.domain.com/folder
我目前的.htaccess文件如下所示:
My current .htaccess file looks as follows:
AddType application/x-httpd-php .html
RewriteEngine On
RewriteBase /
#non www to www
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
#html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L]
#index redirect
#directory remove index.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.html HTTP/
RewriteRule ^index.html$ http://www.arkiq.com/ [R=301,L]
#directory remove index
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index HTTP/
RewriteRule ^index http://www.arkiq.com/ [R=301,L]
#sub-directory remove index.html
RewriteCond %{THE_REQUEST} /index.html
RewriteRule ^(.*)/index.html$ /$1 [R=301,L]
#sub-directory remove index
RewriteCond %{THE_REQUEST} /index
RewriteRule ^(.*)/index /$1 [R=301,L]
#remove .html
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]
我不知道这是较有可能太困难的问题却解决了我的AP preciate你看它不过。
I do realize this is more likely than not too difficult of a question to solve however I do appreciate you looking at it nevertheless.
您需要添加一些其他的规则,除了删除了结尾的斜线。随着 DirectorySlash关
,从没有斜线重定向到斜线停止,但如果你访问任何目录下,它会的打印目录的内容,而不是的显示索引文件
You need to add a couple of other rules besides removing the trailing slash. With DirectorySlash Off
, the redirect from no slash to trailing slash stops, but if you access any directory, it will print the contents of the directory instead of displaying the index file.
这意味着你必须斜线内部添加到目录。因此,改变这些行:
This means you must internally add a trailing slash to directories. So change these lines:
#removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
要:
DirectorySlash Off
#removing trailing slash
RewriteCond %{THE_REQUEST_FILENAME} /(.*)/( |$|?)
RewriteRule ^(.*)/$ $1 [R=301,L]
# internally add the slash back
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ /$1/ [L]