1

I have the entry below in my .conf file that I set up for Jenkins.

 <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>

I redirect fine from my.server.com as expected. But, if I put a URL that doesn't exist such as my.server.com/test it sends me into a redirect loop. I am ok with non existent URLs like /test showing 404 pages, I just want my home page to redirect to /factory.

My Apache knowledge is currently about 0, so if you can explain like I'm 5 that would be great. I'm just trying to get this up and running and plan on continually learning as I go.

gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
gfree
  • 479
  • 7
  • 16

1 Answers1

0

First load mod_rewrite in your Apache and try updated config below.

<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>

Hope that helps!

Community
  • 1
  • 1
slash
  • 593
  • 8
  • 16