Forum Moderators: phranque

Message Too Old, No Replies

keeping redirect url on address bar

         

paulowolf

8:05 pm on Mar 11, 2004 (gmt 0)

10+ Year Member



What can i do to keep the url, ie: blog.manicomio.com.br in address bar?
When i go to this URL, it changes to http://www.example.com.br/blog/ , and i want to keep http://blog.example.com.br/ ..
I can do it?

Sorry about bad english, i'm brazilian..sorry...

[edited by: jdMorgan at 4:02 am (utc) on Mar. 15, 2004]
[edit reason] Examplified URL, de-linked [/edit]

lemat

12:58 am on Mar 12, 2004 (gmt 0)

10+ Year Member



You can set up a virtualhost's in your httpd.conf

NameVirtualHost *

<VirtualHost *>
DocumentRoot /var/www/html/
ServerName example.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /home/user/public_html/blog/
ServerName blog.example.com
</VirtualHost>

erikcw

1:06 am on Mar 12, 2004 (gmt 0)

10+ Year Member



Is there a way to do this for those of us who do not have access to http.conf? (ie .htaccess)

lemat

1:16 am on Mar 12, 2004 (gmt 0)

10+ Year Member



I belive you can't do this without httpd.conf

paulowolf

2:27 am on Mar 12, 2004 (gmt 0)

10+ Year Member



I don't have access to httpd.conf, only .htaccess
I have a linux account in a hosting company.

closed

4:40 am on Mar 12, 2004 (gmt 0)

10+ Year Member



Here's some pseudo-code to get you going:

If REQUEST_URI contains

/blog/
and HTTP_HOST is
www.example.com.br
, redirect (301 or 302) to
http://blog.example.com.br/
.

If HTTP_HOST is

blog.example.com.com.br
, do a silent redirect to the page for
www.example.com.br/blog/
.

[edited by: jdMorgan at 4:03 am (utc) on Mar. 15, 2004]
[edit reason] Examplified URL [/edit]

paulowolf

9:17 am on Mar 12, 2004 (gmt 0)

10+ Year Member



where i use this code?

woro2006

1:26 pm on Mar 12, 2004 (gmt 0)

10+ Year Member



Paulowolf, Welcome to Webmasterworld.
Two things.
1st - you have to remove your domain name, since it violates the rules of webmasterworld. Use a pseudo-domain
2nd - I have put psuedo-code suggested by closed into working code. I do know how well this will work, and I see no serious problems caused by your web host rewrite rule.
However, here is the code that you put into your .htaccess file

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteCond %{REQUEST_URL} ^/blog/
RewriteRule ^(.*) [blog.example.com$1...] [R=301,L]
RewriteCond %{HTTP_HOST} ^(blog)\.example\.com [NC]
RewriteRule ^(.*) [example.com...] [L]