mod-rewrite,URL变量变量、mod、rewrite、URL

由网友(卖梦商人@)分享简介:我怎样才能改变这样的:(1)http://test.com/?page=home这个:(2)http://test.com/home我想它,这样,如果你输入(2)服务器发送(1)解决方案 RewriteEngine叙述上的RewriteBase /重写规则^家居/?$ /?页=家里[L]这使用户可以输入任一家...

我怎样才能改变这样的:

 (1)http://test.com/?page=home
 

这个:

 (2)http://test.com/home
 

我想它,这样,如果你输入(2)服务器发送(1)

解决方案

  RewriteEngine叙述上
的RewriteBase /
重写规则^家居/?$ /?页=家里[L]
 
Httpservlet UrlReWrite重写URL路径 iDea

这使用户可以输入任一家居家用/ 。删除 / 如果你不想让尾随 /

如果你想要更多的活力和希望像任何路径 /商店来重定向到 http://test.com/?page=shop 然后用这个来代替:

  RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{QUERY_STRING}!^页
重写规则^(。*)/?$ /?页= $ 1 [L]
 

How can I change this:

(1) http://test.com/?page=home

into this:

(2) http://test.com/home

I want it so that if you type (2) the server sends (1)

解决方案

RewriteEngine On
RewriteBase /
RewriteRule ^home/?$ /?page=home [L]

This allows the user to type either home or home/. Remove the /? if you don't want to allow the trailing /.

If you want it more dynamic and want any path like /shop to redirect to http://test.com/?page=shop then use this instead:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !^page
RewriteRule ^(.*)/?$ /?page=$1 [L]