Apache htaccess 在 URL 中发送 URLs

Apache htaccess sending URLs in a URL

我正在尝试在 URL 中发送 URL,中间有 ModRewrite。

这是重写规则。它用于搜索用户的个人资料。

RewriteEngine On RewriteRule ^(query)/(profile)/([a-z0-9:.()\-\ ]+)/?$ search/index.php?scope=&query= [NC,L]

这是 URL

http://www.example.com/query/profile/http://www.facebook.com/example

无论我如何执行重写规则,我都会得到 NetworkError: 500 Internal Server ErrorNetworkError: 404 Not Found 如果它是我放在那里的 URL。

我怎样才能正确地做到这一点?我正在使用 Windows 7 家庭高级版。我错过了什么吗?

上面的URL是使用ajax传递的。

编辑:

#htaccess in site1 folder
RewriteRule ^resources/?(.*)/?$ /control/ [NC,L]

#htaccess in control folder
RewriteRule ^(query)/(profile)/([a-z0-9:.()\-\ ]+)/?$ search/index.php?scope=&query= [NC,L]

next folder is `search` which has `index.php`

URL used
http://www.example.com/resources/query/profile/http://www.facebook.com/example

编辑: 我像下面那样重写了 RewriteRule,现在没有收到任何错误消息,但是 Apache 似乎在 http:// 之后从 url 中删除了一个 /。所以我只得到 http:/www.facebook.com/example。任何帮助将不胜感激。

RewriteRule ^(query)/(profile)/([a-z0-9\/:.()\-\ ]+)/?$ search/index.php?scope=&query= [NC,L]`

您需要从 RewriteCond 中捕获 URL,否则 Apache 会将 trim 多个 // 合并为一个。

在 root .htaccess 中更改此规则:

RewriteCond %{REQUEST_URI} /resources/(.+)$ [NC]
RewriteRule ^ /control/%1 [L]

/control/.htaccess 文件中有这个:

RewriteEngine On
RewriteBase /control/

RewriteCond %{REQUEST_URI} /(query)/(profile)/(.+)$ [NC]
RewriteRule ^ /resources/search/index.php?scope=%2&query=%3 [QSA,L]