重定向到没有扩展名而不是目录的文件

时间:2015-03-11 20:43:55

标签: html apache .htaccess

我有一个用于删除文件扩展名的htaccess文件。除了一件事,它的工作非常好。在我的根文件夹中,我有一个名为dogs.html的文件和一个名为dogs的文件夹。当我写localhost:8081 /狗它给我403错误。我希望它能显示dogs.html。它与我的根文件夹中的其他文件完美配合。

这是我的代码:

Options -Indexes ErrorDocument 403 /errors/403-forbidden.html ErrorDocument 404 /errors/404-not-found.html RewriteBase / RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)/?$ $1.html [L]

我想要的是输入localhost:8081 / dogs我想重定向到localhost:8081 / dogs.html而无需在地址栏中添加扩展名。

这是我的目录结构: root | -- css(folder) | | -- dogs(folder) | | | -- dog.css | | | | -- dogs.css | | -- contact.css | | -- dogs(folder) | | -- dog1.html | | -- dog2.html | | -- dogs.html | -- contact.html

dog1和dog2使用相同的css文件(dog.css)

当删除扩展名时,它认为我的意思是文件夹,因为我关闭了索引它会引发403错误。

0 个答案:

没有答案