重写QUOT&; pretty的网址"? [英] Rewrite to "pretty URL"?

查看:314
本文介绍了重写QUOT&; pretty的网址"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么,我想实现的一个例子。

原网址:
http://subdomain.domain.com/company.php?test=TES001

重写的网址:
http://subdomain.domain.com/company/AAA001

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteBase /
重写规则公司/(.*)/(.*)/$ /company.php?$1=$2
的ErrorDocument 404 /
 

解决方案

如果你想 /company.php?test=AAA001 来重定向到 /公司/ AAA001 ,做到这一点:

 的RewriteCond%{QUERY_STRING}测试=([AZ] + [0-9] +)
重写规则^ company.php /公司/%1? [R]
 

如果你想 /公司/ AAA001 来改写为 /company.php?test=AAA001 ,做这样的:

 重写规则的公司/([AZ] + [0-9] +)$ /company.php?test=$1
 

This is an example of what I am trying to achieve.

The original URL:
http://subdomain.domain.com/company.php?test=TES001

The rewritten URL:
http://subdomain.domain.com/company/AAA001

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule company/(.*)/(.*)/$ /company.php?$1=$2
ErrorDocument 404 /

解决方案

If you want /company.php?test=AAA001 to redirect to /company/AAA001, do this:

RewriteCond %{QUERY_STRING} test=([A-Z]+[0-9]+)  
RewriteRule ^company.php /company/%1? [R]    

If you want /company/AAA001 to be rewritten as /company.php?test=AAA001, do this:

RewriteRule company/([A-Z]+[0-9]+)$ /company.php?test=$1

这篇关于重写QUOT&; pretty的网址"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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