1

I have a vhost that needs to redirect / to /app and I use following to accomplish that in vhost.conf:

RewriteEngine On
RewriteRule ^/$ /app [R]

but it's giving me hard time since users get http://server.com//app address.

How to fix that?

2
  • I don't get double slashes when I put those rules in a blank vhost.
    – Jon Lin
    Jan 13, 2013 at 12:22
  • Your rules seem OK.
    – Khaled
    Jan 13, 2013 at 12:26

2 Answers 2

1
suku@ubuntu-vm:/var/www/local$ grep Redirect /etc/apache2/sites-available/default
        RedirectMatch ^/$ /app

suku@ubuntu-vm:/var/www/local$ curl http://127.0.0.1/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://127.0.0.1/app">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>
1
  • 1
    Ok I found my problem. After redirecting, the application itself redirects the page to /login. So to avoid double redirect I simply redirect the root to correct page at the first place. RewriteEngine On RewriteRule ^/$ /app/login.axvw [R] Thanks for all :) Jan 13, 2013 at 12:36
1

It seems like after redirecting, the application itself redirects the page to /login.

So to avoid double redirect simply redirect the root / to the correct page and add this to the apache config in your /etc/apache/sites-available/vhost.conf:

RewriteEngine On
RewriteRule ^/$ /app/login.axvw [R]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .