重写为“漂亮的 URL"? [英] Rewrite to "pretty URL"?

查看:28
本文介绍了重写为“漂亮的 URL"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在努力实现的一个例子.

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

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

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

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

推荐答案

如果您希望 /company.php?test=AAA001 重定向到 /company/AAA001,这样做:

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]    

如果您希望将 /company/AAA001 重写为 /company.php?test=AAA001,请执行以下操作:

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

这篇关于重写为“漂亮的 URL"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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