Mod rewrite mod_rewrite强制子文件夹使用SSL

Mod rewrite mod_rewrite强制子文件夹使用SSL,mod-rewrite,url-rewriting,https,rewrite,Mod Rewrite,Url Rewriting,Https,Rewrite,我尝试从一个特殊的文件夹重定向到一个特殊的主机 当有人进来时,他应该被重新引导到 我所拥有的是文档根目录中的.htaccess文件。。但它需要工作:( 有什么想法吗 更新: 现在我使用它,它在vhost的apache配置文件中工作: RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} (^|\.)mydomain\.com$ [NC] RewriteCond %{REQUEST_URI} ^/administrat

我尝试从一个特殊的文件夹重定向到一个特殊的主机

当有人进来时,他应该被重新引导到

我所拥有的是文档根目录中的.htaccess文件。。但它需要工作:(

有什么想法吗

更新:

现在我使用它,它在vhost的apache配置文件中工作:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (^|\.)mydomain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/administrator/ [NC]
RewriteRule ^/(.*)$ https://a-otherdomain.com/mydomain.com/$1 [R=301,L]
谢谢,
Thomas

重写规则与URI中的前导斜杠不匹配

请尝试以下代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (^|\.)mydomain\.com$ [NC]
RewriteRule ^administrator(/.*|)$ https://a-otherdomain.com/mydomain.com/$0 [R=302,L,NC]

确认其正常工作后,将
R=302
替换为
R=301
。避免使用
R=301
(永久重定向)测试你的mod_重写规则时。

不知道为什么,但规则只在apache配置上有效,而在htaccess上无效。现在它可以工作了-但你的重写条件不对,因为它重定向了所有页面-谢谢
,因为它重定向了所有页面
不请查看
重写规则^administrator(/.*$
行,该行仅重定向以文本开头的所有URI
/administrator/
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (^|\.)mydomain\.com$ [NC]
RewriteRule ^administrator(/.*|)$ https://a-otherdomain.com/mydomain.com/$0 [R=302,L,NC]