mod-rewrite,URL变量 [英] Mod rewrite, url variables

查看:138
本文介绍了mod-rewrite,URL变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能改变这样的:

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

这个:

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

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

解决方案

  RewriteEngine叙述上
的RewriteBase /
重写规则^家居/?$ /?页=家里[L]
 

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

如果你想要更多的活力和希望像任何路径 /商店来重定向到 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]

这篇关于mod-rewrite,URL变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆