开发者

url rewriting with .htaccess

I found some question about url rewriting: .htaccess: Problem with URL rewriting or .htaccess question - URL-rewriting

i tried their method but doesnt work in my case? mine look simple:

http://example.org.uk/member/home.php?profile --> http://example.org.uk/member/home/profile/
http://example.org.uk/member/home.php?history --> http://example.org.uk/member/h开发者_如何转开发ome/history/

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^home/([0-9][0-9])/$ /home.php?$1
RewriteRule ^/([^/]+).php$ /home.php?$1 [L]

any thougt is appricated? thanks


Your making it a bit complicated, the following should work

http://example.org.uk/member/home.php?profile --> http://example.org.uk/member/home/profile/
http://example.org.uk/member/home.php?history --> http://example.org.uk/member/home/history/



RewriteRule ^/member/home/(.*)/ /home.php?$1 [L]

or more generally

RewriteRule ^/(.*)/(.*)/(.*)/ /home.php?$3 [L]


In RewriteRule you have "^/([^/]+).php$", but you don't want .php extension in URLs. Remove .php from rewrite rule. Something like this should work:

RewriteRule ^/member/home/.*$ /member/home.php?$1 [L]


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/member/home/([a-zA-z0-9]+)/$ /member/home.php?$1 [L]


it will still look for the ".php" therefore you could use

RewriteRule ^/([^/]*)/$ home.php?$1
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜