English 中文(简体)
URL与摩德再婚,以提供可再生的铀浓缩物
原标题:URL rewriting with mod_rewrite to provide RESTful URLs

The web server is Apache. I want to rewrite URL so a user won t know the actual directory. For example: The original URL:

www.mydomainname.com/en/working/working.php?guwork_id=11

预期的URL:

页: 1

我在回信中补充了以下声明:

RewriteCond %{HTTP_HOST} ^(?!www)([^.]+).mydomainname.com$ [NC]
RewriteRule ^(w+)/(d+)$ /$1/%1/%1.php?%1_id=$2 [L]

Of course I replaced mydomainname with my domain name. .htaccess is placed in the site root, but when I access 页: 1, I got "Object not found".(Of course I replaced mydomainname with my domain name.)

我在回信中补充了以下声明:

RewriteRule ^/(.*)/en/piecework/(.*)piecework_id=([0-9]+)(.*) piecework.mydomainname.com/en/$3

Of course I replaced mydomainname with my domain name. .htaccess is placed in the site root, but when I access 页: 1, I got "Object not found".(Of course I replaced mydomainname with my domain name.)

什么错误?

问题回答

这里快速概述所发生的情况:

RewriteCond %{HTTP_HOST} ^(?!www)([^.]+).mydomainname.com$ [NC]

首先,问题标志应当到底。

1美元(应当)与非www 0或1倍的内容相匹配。

2美元与非特性1或1倍以上的任何东西相匹配,理论上,这些东西会与那里的空白空间相匹配,但可能永远不会与任何东西相匹配。

然后,这要求两个集团之后的米多曼名称。

你的头两个条件是寻找两个单独的集团。

我不敢肯定你是如何重新努力建立你的结构的,但这里是我如何根据你原来的和预期的URLs来写:

RewriteCond %{HTTP_HOST} !^www.mydomainname.com$ [NC]
RewriteCond %{HTTP_HOST} ^(w+).mydomainname.com$ [NC]
RewriteRule ^(w+)/(d+)$ /$1/%1/%1.php?%1_id=$2 [L]

从根本上说,你的首要条件是确保它不会从www.开始(使它更容易成为一个单独的规则)。 第二种情况是,它检查任何可能属于贵国域名前面的字。 然后,你的改写规则将适当调整。

在你的问题中摆脱最后一条通道......

有些人如果我错了,请更正我。 我不记得,你是否必须在轮椅前面,但我却把他们包括进去。

你们正在这样做。 想法是,你将向人们提供友好的地址,而复标准规则将要求这一友好、不存在的网页上,而不让他们看到。 因此,现在,你只能处理一下当他们去看似的URL时需要做的事情,但你却在友好的URL中这样做。 既然在人们直接安放友好的URL时不存在任何规则,那就看着它,说“不成立”

因此添加一条线:

RewriteRule piecework.mydomainname.com/en/(*.) ^/$3/en/piecework/$3?piecework_id=([0-9]+)(.*)

索里说,这是很正确的,但基本想法是,如果把阿帕奇放在你喜欢的URL中的话,那么,他们准备在没有浏览器看到的情况下将注意力转向真实的网页。

Update

我睡觉,正确做事,因此,我刚刚尝试过最好的举动, around。 我将首先尝试一个更加简单的做法,以便首先缩小基本概念。 为此:

RewriteRule www.mydomainname.com/en/piecework/piecework.php?piecework_id=11 piecework.mydomainname.com/en/11

至少,如果你出现错误,就更容易看到什么是 t。





相关问题
URL rewrite in IIS6 - Third party tools

I have collected the following api/sdk/whatever which provide modules for doing url rewriting in IIS 5/6/7. Some are free-open source and some require $. I haven t tried any of them. I would like to ...

Rewrite spring-security redirect URLs

I m trying to get Tuckey UrlRewriteFilter to tidy up URLs for my webapp. One problem I ve got is that when spring-security notices that an anonymous user is trying to access a protected resource it ...

ASP.NET Friendly URLs

In my research, I found 2 ways to do them. Both required modifications to the Application_BeginRequest procedure in the Global.Asax, where you would run your code to do the actual URL mapping (mine ...

Could I get by HttpModule the URL that contains * before?

My web-site is working under ASP.NET 3.5, IIS7, Integrated pipiline mode. My HttpModule is getting request to all resources, including URLs like this: http://my-site.com/address And I would support *...

Domains & Foreward Slash

This is rather difficult to explain so please bear with me. We will be hosting 4 websites on our server and the plan is to have each site sit under its own domain: site-a.com site-b.com sub1.site-b....

URL Mod-Rewrite

I currently have a working URL: http://example.com/security-services.php?service=fixed-camera-surveillance and then I have PHP say, $_REQUEST[ service ] to do some stuff... But I d like to ...

热门标签