Majid Laissi
Majid Laissi

Reputation: 19788

Redirection to another port on the same server

I have a web application in http://example.com:8080/example-app/

When the user types http://example.com/ , I'd like to redirect him to the web app.

Options +FollowSymLinks
RewriteEngine On
RewriteCond   %{HTTP_HOST}   (.*)example.com$         [NC]
RewriteRule ^(.*)$ http://example.com:8080/example-app/$1 [L,R=301]

I believe the .htaccess has the correct access right:

$ ls -altr /var/www/html/.htaccess
-rw-r--r-- 1 apache apache 178 Jul  2 00:31 /var/www/html/.htaccess

But navigating to http://example.com/ just serves the index.html file.

Can someone tell me why this doesn't work? I there a way to debug this? (apache on centos).

Upvotes: 0

Views: 41

Answers (1)

Gulim Shah
Gulim Shah

Reputation: 194

change the server default listening port from 8080 to 80 in configuration file this one is easy or try the proxy tho redirect the request as below and the default Document Root folder

     NameVirtualHost *:8080

    <VirtualHost *>
     ServerAdmin [email protected]
     ServerName www.example.com:8080
     ProxyPreserveHost On

  # setup the proxy
    <Proxy *>
       Order allow,deny
       Allow from all
       </Proxy>
     ProxyPass / http://www.example.com:80/
     ProxyPassReverse / http://www.example.com:80/
   </VirtualHost>

Upvotes: 1

Related Questions