HtAccess: Basic ModRewrite
Given urls like this:
mysite.com/index.php
mysite.com/page/member/lobby.php
mysite.com/page/videos/video1.php
How can I rewrite the开发者_运维技巧 urls with .htaccess to hide the /page/ folder when it's present?
So the end result is:
mysite.com/index.php
mysite.com/member/lobby.php
mysite.com/videos/video1.php
You can use this rule to add page/
to your path internally:
RewriteCond $1 !=page
RewriteRule ^([^/]+)/.+ page/$0 [L]
Now every request that’s URI path has at least two path segments but that’s first segment is not page
will be prefixes with /page
. So /member/lobby.php
will be rewritten to /page/member/lobby.php
.
精彩评论