Apache htaccess重写规则不适用于http://

Apache htaccess重写规则不适用于http://,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,我的重写规则是 RewriteRule ^site/([^/]+)$ page.php?site=$1 [L] 这对我来说很有效 http://example.com/site/google.com 但是当我在google.com之前添加http://或https://时不起作用 http://example.com/site/http://google.com 或 请共享一个重写规则,该规则可以接受/site/之后的所有内容,如您需要从RewriteCond中捕获http://类型字符串

我的重写规则是

RewriteRule ^site/([^/]+)$ page.php?site=$1 [L]
这对我来说很有效

http://example.com/site/google.com
但是当我在google.com之前添加http://https://时不起作用

http://example.com/site/http://google.com


请共享一个重写规则,该规则可以接受/site/之后的所有内容,如

您需要从
RewriteCond
中捕获
http://
类型字符串,否则Apache会在
RewriteRule
模式中将多个斜杠删除为单个斜杠。使用此规则:

RewriteCond %{REQUEST_URI} /site/(.+)$ [NC]
RewriteRule ^ page.php?site=%1 [L,QSA]

我在localhost中执行此操作。我的链接是project/site/目录,我收到404错误。stackoverflow中有一个问题。我将http://before google.com添加到这个htaccess文件和
page.php
文件的位置在哪里?这正在运行重写规则^site/(.*)$page.php?site=$1[L],但是Apache将多个斜杠删除到单个.htaccess文件和页面都在同一个目录中。我认为您的规则不在
DocumentRoot
中。现在试试我更新的规则。
RewriteCond %{REQUEST_URI} /site/(.+)$ [NC]
RewriteRule ^ page.php?site=%1 [L,QSA]