Apache RewriteRule 处理多个域
Apache RewriteRule to handle multiple domains
我正在尝试在 Apache (httpd.conf) 中设置重定向,要求很简单,无论何时访问我的域,这些访问都应该重定向到不同的 URL。我在设置服务器时编写了这段代码,并且只处理了一个域。当只有一个域并正确重定向到目的地时,该代码有效。
我又添加了一个域并尝试进行相同的重定向。不幸的是,在添加第二个域重定向代码后,重定向似乎不起作用。
要求:
重定向 'chk' 和 'enq' 目录下的所有文件到它的移动域
初始重写规则
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
以上代码仅在我拥有域 st-iex.o-p.com 时有效。
我已经更新了处理第二个域重定向的代码
版本 2
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} ^st-iex\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
RewriteEngine On
RewriteCond %{HTTP_HOST} ^st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
代码更新后,它不起作用,也没有进行重定向。
谁能帮我解决这个重定向问题?
我已经更新了 RewriteRule 如下,然后问题现在已经解决了。
谢谢。
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} st-iex\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex\.o-p\.com$ [NC]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/enq/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L, R=301]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
我正在尝试在 Apache (httpd.conf) 中设置重定向,要求很简单,无论何时访问我的域,这些访问都应该重定向到不同的 URL。我在设置服务器时编写了这段代码,并且只处理了一个域。当只有一个域并正确重定向到目的地时,该代码有效。
我又添加了一个域并尝试进行相同的重定向。不幸的是,在添加第二个域重定向代码后,重定向似乎不起作用。
要求:
重定向 'chk' 和 'enq' 目录下的所有文件到它的移动域
初始重写规则
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
以上代码仅在我拥有域 st-iex.o-p.com 时有效。
我已经更新了处理第二个域重定向的代码
版本 2
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} ^st-iex\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
RewriteEngine On
RewriteCond %{HTTP_HOST} ^st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L]
RewriteRule ^/enq/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
代码更新后,它不起作用,也没有进行重定向。 谁能帮我解决这个重定向问题?
我已经更新了 RewriteRule 如下,然后问题现在已经解决了。 谢谢。
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} st-iex\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex\.o-p\.com$ [NC]
RewriteRule ^/enq/q/(.*) https://st-iex.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/chk/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/chk/q/ [L, R=301]
RewriteCond %{HTTP_HOST} st-iex-t\.o-p\.com$ [NC]
RewriteRule ^/enq/q/(.*) https://st-iex-t.o-p.com/lnk000/=https://st-ex.o-p.com/enq/q/ [L, R=301]
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3