2015-06-06 95 views
1

在我的website中,我有一個家庭HTML文件。然後,當我點擊導航中的某個內容時,例如Roster,網址就會變爲http://www.nextgengaming.org/Roster/roster.html。我怎樣才能阻止呢?我並不擔心這個擴展,因爲我可以在以後擺脫它。這裏是我建網站的時候(請注意,我沒有在「名單」的HTML文件,因爲我在URL上聚焦現在)用我的文件/文件夾設置:網站的文件夾組織

Website 
    ∟ Home 
    ∟ CSS 
     HEADER (social icon images) 
     home_files (for my image slider) 
     IMG (the rest of my images) 
     home.html 
     home.js 

    ∟ Roster 
    ∟ roster.html 

我將填補名單與幾乎相同的東西。在我的導航我有

<li><a href="../Roster/roster.html">Roster</a></li>

所以網址是(因爲之前說的)http://www.nextgengaming.org/Roster/roster.html,並希望將其更改爲

http://www.nextgengaming.org/Roster

OR

http://www.nextgengaming.org/roster.html

如果您需要任何mo重新提供信息,請評論。另外,我不確定這是否是正確的發佈地點,但我會抓住機會。

回答

0

網址更改爲http://www.nextgengaming.org/Roster/roster.html我該如何解決這個問題?

建議的方式是通過增加

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html [L] 

注意rewrite必須使能模塊(sudo a2enmod rewrite)編輯虛擬主機的.htaccess。的DirectoryIndexdocumentation here)說起它搜索

index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml 

如果存在沒有資源和Indexes選項設置,服務器將產生它自己的目錄清單。 Indexes可能會導致安全威脅(公開所有文件),以便使用

Options -Indexes 

,以避免這種情況。如果按照指示,

http://www.nextgengaming.org/Roster/roster.html 

將被改寫爲

http://www.nextgengaming.org/Roster/roster 

爲了避免Roster/roster和剛剛rosterroster.htmlDocumentRoot可能旁邊home.html

0

使用默認的擴展名(通常index.html),並更改網址:http://www.nextgengaming.org/Homehttp://www.nextgengaming.org/Roster

的結構將是:

Website 
    ∟ Home 
    ∟ CSS 
     HEADER (social icon images) 
     home_files (for my image slider) 
     IMG (the rest of my images) 
     index.html 
     home.js 

    ∟ Roster 
    ∟ index.html 

如果你不喜歡重命名文件像這樣,更先進的方法就是使用URL重寫(例如使用.htaccess)。