1

这可能是关于 RewriteRule 的一个基本问题,但我无法让它发挥作用。

我想要做的是检测像这样的网址:

mydomain/myapp/id/some/random/url.html?param=somethingThatIdoUse
mydomain/myapp/id/other/randomabc/perrito.php?param=somethingThatIdoUse
... 

我需要删除的部分来自/id/[all this]?param=somethingIdoUse并使用参数,如果可能的话,或者将完整的 url 作为参数发送,这样我就可以通过正则表达式来获取参数。

并有一个规则来检测/id/存在并重定向到类似的东西:

mydomain/myapp/other/manageRequest.php?params=somethingThatIdoUse 

(我可以获得整个网址并将其剥离为字符串的参数没问题)

该应用程序还具有不同的模块,例如:

mydomain/myapp/moduleOne/index.php 
mydomain/myapp/moduleTwo/index.php 

这必须保持不变。

到目前为止,我已经尝试过其中一些,例如:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET /.*;.* HTTP/
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://localhostdev/app/index.php %{REQUEST_URI}? [R=301,L]


RewriteEngine On
RewriteBase /spt/
RewriteCond %{REQUEST_FILENAME} !^id$ [NC]
RewriteRule ^(.*)$ index.php [R=301,L]

RewriteEngine On
RewriteCond %{REQUEST_URI} !/campaings/response\.php$
RewriteRule ^/something/(.*) /other/manageRequest.php? [L]

但是没有什么可以做我需要的。

谢谢指教

4

2 回答 2

2

mydomain/myapp/id/some/random/url.html?param=somethingThatIdoUse

以下是使用上述 URL 的示例:

RewriteRule ^id/some/random/url.html/?  /myapp/other/manageRequest.php [L,NC] 

查询将原封不动地传递到替换 URL

于 2013-04-12T21:42:26.837 回答
1

好吧,实际上最终它是非常基本的:

RewriteRule ^.*id.*$ handleRequest.php [NC,L]

我确实收到了发送的参数!

于 2013-04-12T22:28:28.063 回答