我有一个运行apache访问的网站
http://hostname或http://hostname.local 当内部用户从10.0.1.0/24地址空间访问http://hostname/*或http://hostname.local/*上的任何页面时,如何redirect访问,以便将它们发送到https://hostname.example.org上的相关页面https://hostname.example.org
警告我有两个子网10.0.1.0/24,我想要做的https和10.0.2.0/24,我不想做 HTT的时刻
我现在所拥有的是
RewriteEngine On RewriteBase / RewriteCond %{REMOTE_HOST} 10\.0\.1 RewriteRule .* https://hostname.example.org/ [R=301,L]
但我不知道如何做到这一点,所以如果用户转到http://hostname[.local]/test ,用户被发送到https://hostname.example.org/test
尝试这个:
RewriteRule ^(.*)$ https://hostname.example.org/$1 [R=301,L]
为了使它只有命中hostname.local去那里你添加条件下面的HTTP_HOST并调整RewriteRule。
RewriteEngine On RewriteBase / RewriteCond %{REMOTE_HOST} 10\.0\.1 RewriteCond %{HTTP_HOST} ^hostname\.local$ RewriteRule ^(.*)$ https://hostname.example.org/$1 [R=301,L]