2010-12-03 17 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] 

从这个任何简单或更好?