开发者

How to make my url looks cool with htaccess

regulars question :P

Current URL

http://domain.com/index.php
http://domain.com/index.php?page=submit-hosting
http开发者_如何学Go://domain.com/index.php?page=popular-hosting

How write my .htaccess to make current URL to be like this

  1. When user type http://domain.com/index.php url will return to http://domain.com/ only without index.php

  2. And page with$_GET['page'] to be http://domain.com/submit-hosting/

Let me know :)


From Google I got

to remove index.php or index.html

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

to make end with slash

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

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

to make /page-name/

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

Any simple or better from this one?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜