You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Jha, Sanjeev" <sj...@rational.com> on 2002/11/26 18:48:58 UTC
[users@httpd] Rewrite question
I have a rewrite question on which I am trying different options but not
getting exactly what I am looking for-
I am looking for -- Redirect http://domain.com to http://www.domain.com (
for example).
Note that using DNS, domain.com IS pointing to same IP www.domain.com and
therefore http://domain.com works but for some other reason, we want the URL
to be changed to http://www.domain.com if someone just comes through
http://domain.com.
I tried following --
1> RewriteRule ^(domain.com)(/)$ http://www.domain.com/$1 [R]
--> didn't work. Doing nothing.
2> RewriteRule ^(.*)(/)$ http://www.domain.com$1/ [R]
--> I noticed, it's keep redirecting and site never comes up.
3> RewriteRule ^(.*)(/)$ http://www.domain.com$1/index.html [R]
--> This one works. But the problem is I have some part of web site where
there is no index.html but index.jsp or index.htm page only. Therefore
getting 404 for those.
4> RewriteCond %{HTTP_HOST} !^domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.domain.com/$1 [L,R]
--> Trying to copy one of the example on apache.org. I might be missing
something. After this change, the site keep redirecting itself to
www.domain.com and like in #2, it never came up.
5> RewriteRule http://domain.com/(.*) http://www.domain.com/$1 [R]
--> Don't know why I did this, but didn't work either
6> I tried setting up Virtual host for "ServerName domain.com" and
"Redirect / www.domain.com" . Nothing happened.
Any suggestion ?
Thanks,
-Sana
Re: [users@httpd] Rewrite question
Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 26 Nov 2002, Jha, Sanjeev wrote:
> I have a rewrite question on which I am trying different options but not
> getting exactly what I am looking for-
>
> I am looking for -- Redirect http://domain.com <http://domain.com> to
> http://www.domain.com <http://www.domain.com> ( for example).
Have you looked at
http://httpd.apache.org/docs/misc/FAQ.html#canonical-hostnames
The following two come closest:
>
> 4> RewriteCond %{HTTP_HOST} !^domain\.com [NC]
> RewriteCond %{HTTP_HOST} !^$
> RewriteRule ^/(.*) http://www.domain.com/$1
> <http://www.domain.com/$1> [L,R] --> Trying to copy one of
> the example on apache.org. I might be missing something. After this
> change, the site keep redirecting itself to www.domain.com and like in
> #2, it never came up.
The first line says "follow these rules if the domain is NOT domain.com.
You want to change that to www.domain.com.
> 6> I tried setting up Virtual host for "ServerName domain.com"
> and "Redirect / www.domain.com" . Nothing happened.
That is not a proper redirect. You need
Redirect / http://www.domain.com
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org