虚拟主机中的apache重定向循环
我在为Jenkins设置的.conf文件中有下面的条目虚拟主机中的apache重定向循环,apache,redirect,Apache,Redirect,我在为Jenkins设置的.conf文件中有下面的条目 <VirtualHost *:80> ServerName my.server.com Redirect 301 / http://my.server.com/factory ProxyPass /factory http://localhost:8080/factory nocanon ProxyPassReverse /fact
<VirtualHost *:80>
ServerName my.server.com
Redirect 301 / http://my.server.com/factory
ProxyPass /factory http://localhost:8080/factory nocanon
ProxyPassReverse /factory localhost:8080/factory
ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/factory*>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
我按预期从my.server.com重定向fine。但是,如果我放置了一个不存在的URL,比如my.server.com/test,它会将我发送到一个重定向循环中。我可以使用不存在的URL,比如显示404页的/test,我只希望我的主页重定向到/factory
我的Apache知识目前大约为0,所以如果你能像我5岁那样解释,那就太好了。我只是想让它运行起来,并计划在运行中不断学习。然后尝试下面更新的配置
<VirtualHost *:80>
ServerName my.server.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^my\.server\.com$ [NC] # if host is my.server.com
RewriteCond %{REQUEST_URI} !(^/factory$) [NC] # and request uri is NOT factory
RewriteRule ^(.*)$ http://my.server.com/factory [R=301,L] # redirect to url
ProxyPass /factory http://localhost:8080/factory nocanon
ProxyPassReverse /factory localhost:8080/factory
ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/factory*>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
希望有帮助