我知道这个问题已经被问过,但没有人知道的隐藏HTML扩展的好办法。我尝试过很多codeS&放大器;许多来自 http://stackoverflow.com/ 的答案,但我没有看到的结果。这就是Y I问你再次
I know this question has been asked before but does anyone know of a good way to hide .html extensions. I've tried many of codes & many of the answers from the http://stackoverflow.com/ but am not seeing the result. Thats y I ask u again
我有一个静态的网站,我想删除的扩展清理我的网址。我正与静态HTML文件。
I've a static website and I wanted to remove the extension to clean my urls. I was working with static html files.
在移除扩展,网址会读 website.com/about.html
。
Prior to removing the extension, the url would read website.com/about.html
.
通过扩展删除,它看起来像website.com/about。希望是明确的。
With the extension removed, it would look like website.com/about. Hope that was clear.
我有.htaccess文件,我试过很多的codeS,但忽略了最低的工作。下面是C $ CS约$
I've a .htaccess file and I tried many of the codes but it dosen't work. Here are some codes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ /$1 [L,R=301]
RewriteCond %{THE_REQUEST} /(.+/)?index(.html)?(?.*)? [NC]
RewriteRule ^(.+/)?index(.html)?$ /%1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+).html$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.html HTTP/
RewriteRule ^index.html$ http://%{HTTP_HOST}/ [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [NC,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
RewriteBase /
RewriteEngine on
RewriteRule ^(.*).htm$ $1.html [nc]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*.html$ %{REQUEST_FILENAME}.html [L]
不过,我没有看到任何结果... :(
however I am not seeing any results...:(
你有你的规则颠倒(第一个会工作,否则):
You have your rule reversed (the first one would work otherwise):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L]
您最初的规则是重写规则^(。*)。HTML $ $ 1 [L]
翻译过来就是如果请求的资源名称结尾的.html
然后发出一个重定向到浏览器,告诉它要问我们,如果我们在相同的名称没有任何的HTML。这导致404(因为阿帕奇没有什么,以服务为的.html
占用资源少)。
Your original rule was RewriteRule ^(.*).html$ $1 [L]
which translates to "If the requested resource name ends with .html
then issue a redirect to the browser telling it to ask us if we have anything at the same name without the HTML". This results in a 404 (since Apache doesn't have anything to serve for the .html
'less resource).
通过切换的.html
目的地重写规则^(。*)$ $ 1.HTML [L]
我们改变规则说如果所请求的资源名称不是磁盘上的文件或目录,然后尝试重新将请求路由(内部,不告诉浏览器),就好像它在结束。 HTML
By switching the .html
to the destination RewriteRule ^(.*)$ $1.html [L]
we change the rule to say "If the requested resource name is not a file or directory on disk then try to re-route the request (internally, don't tell the browser) as if it ended in .html
".