2013-06-19 39 views
0

我看了幾篇關於設置「漂亮網址」的文章,我似乎無法爲我工作。我是整個.htaccess過程的新手,看起來我所看到的所有內容都適用於基於.PHP的動態網站。這是我想看到發生什麼事:從純html頁面創建漂亮的網址?

醜陋網址:http://www.example.com/test.html
漂亮網址:http://www.example.com/test/

什麼是我目前正在試圖在.htaccess文件中使用的是:

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule ^([a-z]+)$ $1.html 

至此,我沒有運氣。我沒有在頁面上使用任何形式的.php - 這些是靜態的.html頁面。任何幫助將不勝感激。謝謝!

+0

http://stackoverflow.com/q/9309380/139010 –

+0

感謝您的評論!我給解決方案的頁面一個鏡頭(只是改變了這一行: –

+0

感謝您的意見!我給解決方案頁面一個鏡頭(並只是改變了這一行: RewriteRule([^。] +)\。html http ?://www.quotist.com/$1/%1/%2 [L,R = 301] 同500錯誤消息 這裏是我使用新的.htaccess代碼: 選項+的FollowSymLinks - 多視圖-Indexes RewriteEngine敘述上 RewriteBase/ 的RewriteCond%{ENV:REDIRECT_STATUS} 200 重寫規則^ - [L] 的RewriteCond%{QUERY_STRING} ^(字母)=(\ w)的$ [NC] RewriteRule([^。] +)\。html http://www.igeniusstore.com/$1/%1/%2? [L,R = 301] RewriteCond%{REQUEST_URI}^/([\ w - ] +)/(letter)/ \ w /? [NC] 重寫規則^ /%1.html?%2=%3 [L,QSA] –

回答

1

沒關係。我找出了什麼問題。我的編譯器正在破壞.htaccess文件,該文件在加載時觸發站點範圍的錯誤消息。你可以看到,它的工作現在在這裏:

http://www.igeniusstore.com/this-test.html

http://www.igeniusstore.com/this-test

下面是我使用的基本代碼:

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

感謝所有的幫助。乾杯!

+0

你的代碼不工作 –