隐藏扩展名在.htaccess
问题描述:
大家好 我有我的文件具有的.html extention一个问题,但我想,当brownser打开该文件进一步扩展了hidden.e.g file.html到文件。 先感谢隐藏扩展名在.htaccess
答
在你.htaccess
文件中使用这样的:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
现在你可以使用像林家http://www.mysite.com/contact
而非http://www.mysite.com/contact.html
。
希望这会有所帮助!
答
您的链接必须是这样的
<a href="example">Example</a>
Instead of
<a href="example.php">Example</a>
然后添加到您的.htaccess文件
RewriteCond ^example example.php [L]
答
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{ REQUEST_FILENAME}的.html -f
重写规则^(。*)$ $ 1.HTML
这一个是确定在一个网站的单一扩展。我在同一个网站中使用了多个扩展,例如index.html和contact.php。
我怎么能使用此代码?
答
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
例yoursite.com/wallpaper.html到yoursite.com/wallpaper/
感谢,但问题是,他们表现出在浏览器中的联系人页面,但是当我在浏览器contact.html写到这里extentionshow直到刷新页面。 – user716987 2011-04-20 11:21:22
我读到contact.html,你已经失去了我。你在做什么? – ThisDarkTao 2011-04-20 11:30:59
制作一个页面contact.html并编写.htaccess并通过以上代码打开浏览器中的.htaccess.now文件,它们会显示您的联系人,但问题是,当您在浏览器中使用联系人页面编写.html时,但我想extention不会显示如果我写在浏览器中的.html extention然后页面没有想到这extention。看到这个链接http://www.myatlantainjurylawyer.com/ – user716987 2011-04-20 11:55:41