2011-04-20 117 views
2

大家好 我有我的文件具有的.html extention一個問題,但我想,當brownser打開該文件進一步擴展了hidden.e.g file.html到文件。 先感謝隱藏擴展名在.htaccess

回答

5

在你.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

希望這會有所幫助!

+0

感謝,但問題是,他們表現出在瀏覽器中的聯繫人頁面,但是當我在瀏覽器contact.html寫到這裏extentionshow直到刷新頁面。 – user716987 2011-04-20 11:21:22

+0

我讀到contact.html,你已經失去了我。你在做什麼? – ThisDarkTao 2011-04-20 11:30:59

+0

製作一個頁面contact.html並編寫.htaccess並通過以上代碼打開瀏覽器中的.htaccess.now文件,它們會顯示您的聯繫人,但問題是,當您在瀏覽器中使用聯繫人頁面編寫.html時,但我想extention不會顯示如果我寫在瀏覽器中的.html extention然後頁面沒有想到這extention。看到這個鏈接http://www.myatlantainjurylawyer.com/ – user716987 2011-04-20 11:55:41

0

您的鏈接必須是這樣的

<a href="example">Example</a> 
Instead of 
<a href="example.php">Example</a> 

然後添加到您的.htaccess文件

RewriteCond ^example example.php [L] 
0

RewriteEngine敘述上
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{ REQUEST_FILENAME}的.html -f
重寫規則^(。*)$ $ 1.HTML

這一個是確定在一個網站的單一擴展。我在同一個網站中使用了多個擴展,例如index.html和contact.php。

我怎麼能使用此代碼?

1
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/

相關問題