我无法让我的htaccess文件隐藏所有文件扩展名(在我的情况下的HTML和PHP)。无法隐藏所有扩展使用htaccess
如果我在 'example.com/home.html' 型,
我想 'example.com/home' 显示在地址栏中。
这是可能的与htaccess没有改变我的html代码到'href =“/ home”'?
在此先感谢。
我无法让我的htaccess文件隐藏所有文件扩展名(在我的情况下的HTML和PHP)。无法隐藏所有扩展使用htaccess
如果我在 'example.com/home.html' 型,
我想 'example.com/home' 显示在地址栏中。
这是可能的与htaccess没有改变我的html代码到'href =“/ home”'?
在此先感谢。
搜索了一些,发现你已经在另一篇文章中提供了解决方案。
# browser requests html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.html
RewriteRule ^/?(.*)\.html$ /$1 [L,R=301]
# check to see if the request is for a html file:
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^/?(.*)$ /$1.html [L]
尝试:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+(.+)\.html(\?\)
RewriteRule^/%1 [L,R=301]
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.*)$ /$1.html [L]
在你的文档根htaccess文件
。
不好。与我找到的其他代码结果相同。它允许文件tp在没有扩展名的情况下运行,但它仍然显示在地址栏中。 – Kev 2014-09-24 00:14:51
此解决方案是否适合您隐藏'.php'扩展名? – anubhava 2014-09-24 05:32:27
只需html。我想象如果你将代码中的所有html替换为你想要隐藏的扩展,它就会工作。 – Kev 2014-09-28 22:20:33