Forum Moderators: buckworks & webwork

Message Too Old, No Replies

redirect based on domain name

new domain name pointer... want it redirect to a sub-folder

         

wwhite

11:30 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



I recently registered a new domain name and had my hosting company make it point to my server. I want it to send the user to a subfolder upon the users requesting the domain name. (ex. "www.myserver.com" is my original domain name. I just registered "www.mynewdomain.com". When a user requests "www.mynewdomain.com" I want them to be sent to "www.myserver.com/myfolder".) Can anyone help me? Thanks

jdMorgan

11:36 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to mention what server you're hosted on - Apache and IIS require different solutions.

Jim

wwhite

12:09 am on Apr 11, 2003 (gmt 0)

10+ Year Member



sorry... its apache. I tried useing the .htaccess by entering: Redirect newdomain.com/ [mysite.com...] Thanks for the quick reply.

jdMorgan

1:09 am on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wwhite,

Adding something like this to your .htaccess file will redirect requests to the subdomain "subdomain1" to the subdirectory "/subdomain1"

RewriteEngine On
Options +FollowSymlinks
# Rewrite rule for subdomain1.mydomain.com
RewriteCond %{HTTP_HOST} ^subdomain1\.mydomain\.com
RewriteCond %{REQUEST_URI}!^/subdomain1
Rewriterule ^(.*)$ /subdomain1/$1 [L]

You should then treat subdirectory "subdomain1" as the web root directory of subdomain "subdomain1" - You should place a robots.txt file there, for example, if you wish to control search engine spidering of subdomain1

See also this thread [webmasterworld.com]. Things get going on the second page.

Hope this helps, and since I forgot my manners the first time, Welcome to WebmasterWorld [webmasterworld.com]!

Jim

Filipe

4:15 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Yeah, using MOD REWRITE is one of the safer methods. If you try to do a non-server-side redirect, you may suffer the consequences with SEs.

wwhite

1:04 am on Apr 13, 2003 (gmt 0)

10+ Year Member



Thanks for all the help put I conintue to get internal server errors when I put that code in my .htaccess file. Do you see any problems in the way I have it setup?

ErrorDocument 404 [willsdj.com...]
ErrorDocument 401 [willsdj.com...]
ErrorDocument 500 [willsdj.com...]

RewriteEngine On
Options +FollowSymlinks
# Rewrite rule for nexpost.net
RewriteCond %{HTTP_HOST} ^nexpost\.net
RewriteCond %{REQUEST_URI}!^/nexpost
Rewriterule ^(.*)$ /nexpost/$1 [L]

IndexIgnore *

AddType application/x-httpd-php4 .php
Action application/x-httpd-php4 "/cgi-bin/php"

jdMorgan

1:33 am on Apr 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wwhite,

Yes, I see a problem...
I messed up the order of the first two directives - Google update fever, I guess... ;)

Options +FollowSymlinks
RewriteEngine On
# Rewrite rule for nexpost.net
RewriteCond %{HTTP_HOST} ^nexpost\.net
RewriteCond %{REQUEST_URI} !^/nexpost
Rewriterule ^(.*)$ /nexpost/$1 [L]

IndexIgnore *

If you wish to completely suppress directory listings in your directories to prevent people poking around, use


Options +FollowSymLinks -Indexes

as the first line instead. In that case, you won't need the IndexIgnore directive.

If you continue to get errors, see if you can access your raw error log or, as a last resort, the error report in your stats. It would help to know what error is reported.

Sorry for the error.

Jim

wwhite

12:07 am on Apr 14, 2003 (gmt 0)

10+ Year Member



Well... no more error, but still not action. I put that in the .htaccses file but when you plug www.nexpost.net into your browser it still shows the root of www.willsdj.com. Are there any other methods besided this one? Sorry this is so difficult.

jdMorgan

12:55 am on Apr 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change the first RewriteCond:

RewriteCond %{HTTP_HOST} ^(www\.)?nextpost\.net


That will pick up nextpost.net or www.nextpost.net

Jim