2010-12-03 40 views
0

常客問題:P如何使我的URL看起來很酷與htaccess的

當前URL

http://domain.com/index.php 
http://domain.com/index.php?page=submit-hosting 
http://domain.com/index.php?page=popular-hosting 

如何寫我.htaccess使當前的URL是這樣

  1. 當用戶類型http://domain.com/index.php url只會返回到http://domain.com/而沒有index.php

  2. 和頁面與$_GET['page']http://domain.com/submit-hosting/

讓我知道:)

回答

0

從谷歌我

刪除index.phpindex.html

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(html?|php)(\?.*)?\ [NC] 
RewriteRule ^(.+/)?index\.(html?|php)$ ./$1 [R=301,L] 

做出最終與斜線

RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] 

RewriteCond %{REQUEST_URI} ^(/.*[^/])/?$ 
RewriteCond %{DOCUMENT_ROOT}%1.php -f 
RewriteRule ^([^/]+)/?$ ./$1.php [QSA,L] 

撥打/頁名/

RewriteRule ^([^/]*)/$ ./index.php?page=$1 [QSA,L] 

從這個任何簡單或更好?