阿帕奇的.htaccess URL重写 [英] Apache .htaccess URL Rewriting

查看:106
本文介绍了阿帕奇的.htaccess URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从这个更改网址:

http://opportunityfinance.net/industry/industry_locator_proc.asp?organization={ORGANIZATION NAME}

http://opportunityfinance.net/industry/industry_locator_proc.asp?organization={ORGANIZATION NAME}

要这样的:

http://opportunityfinance.net/industry/ {机构名称}

同时还访问第一个URL。其中{机构名称}可以等于一堆不同的名字,真的什么。

while still accessing the first url. Where {ORGANIZATION NAME} can equal a bunch of different names, really anything.

必须有一个简单的方法来使用.htaccess文件的权利这样做?

There must be an easy way to do this with a .htaccess file right?

或者,也许这将是更好,如果我们把它改成这样:

Or maybe it would be better if we changed it to this:

http://opportunityfinance.net/organization= {机构名称}

较容易我想对我的作品。 谢谢,你们这里是真棒!

whichever is easier I guess works for me. Thanks, you guys here are awesome!

推荐答案

您必须首先获取查询字符串部分用的 的RewriteCond 和的客户端重定向到新的URL

You must first capture the query string part with a RewriteCond and redirect the client to the new URL

RewriteEngine on
RewriteCond %{ENV:REDIRECT_SEO} !1
RewriteCond %{QUERY_STRING} organization=(.+)
RewriteRule ^/?industry/industry_locator_proc.asp /industry/%1? [R,L]

现在的客户端请求新的URL和您服务从现有的ASP请求

Now the client requests the new URL and you serve the request from the existing ASP

RewriteCond %{REQUEST_URI} !industry_locator_proc.asp
RewriteRule ^/?industry/(.*) /industry/industry_locator_proc.asp?organization=$1 [E=SEO:1,L]

环境设置 E = SEO:1 prevents无限循环

The environment setting E=SEO:1 prevents an endless loop.

当一切工作,因为它应该,你可以替换研究 R = 301

When everything works as it should, you can replace R with R=301.

这篇关于阿帕奇的.htaccess URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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