Forum Moderators: phranque

Message Too Old, No Replies

Can I "clone" a subdomain?

subdomain redirect subdirectory hide conceal

         

rebayona

1:20 am on Jul 15, 2005 (gmt 0)

10+ Year Member



Hi. I'll try to explain myself the best I can.

Hi have a php application on:

http://example.com/sub/

There is a subdomain pointing to that location:

http://sub.example.com

Everything's OK, application works very well.

But I have this subdomain: http://anothersub.example.com

I need http://anothersub.example.com to redirect to http://example.com/sub/ OR http://sub.example.com (it doesn't matter), AND to keep in the address bar the http://anothersub.example.com
Also, If I go to http://anothersub.example.com/1.htm it should work, but the real location is http://example.com/sub/1.htm

I hope I made myself clear. Can you guys help me here? Is this a hidden redirection?

This is what I have now:
.htaccess at /anothersub:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^anothersub.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.anothersub.exampler.com$
RewriteRule ^(.*)$ http://sub.example.com [R=301,L]

[edited by: jdMorgan at 3:03 am (utc) on July 16, 2005]
[edit reason] Example.com [/edit]

rebayona

1:21 am on Jul 15, 2005 (gmt 0)

10+ Year Member



ignore myserver or mydomain ... it is the same domain (my mistake) ;)

jdMorgan

3:10 am on Jul 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rebayona,

Welcome to WebmasterWorld!

You can't use a redirect if you want to 'keep the address in the address bar' -- It's a matter of definition, because a redirect *will* change the address bar as the client responds to the redirect. Instead, use a server-internal rewrite (you said 'hidden redirect') to do this.


RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?anothersub\.example\.com
RewriteCond $1!sub
RewriteRule (.*) /sub/$1 [L]

Note: Do not end-anchor the domain name; If a client appends a port number, it will break your rule. Also, escape the literal periods in regular-expressions patterns as shown by preceding them with a backslash.

The first RewriteCond combines both of your original RewriteConds.

The second RewriteCond prevents an infinite rewriting loop.

Flush your browser cache (Temporary Internat Files) before testing each change to the code.

Jim

rebayona

5:10 pm on Jul 17, 2005 (gmt 0)

10+ Year Member



Hi, thanks a lot for your reply.

I did exactly what you suggested, but it didn't work. This is the error I got:

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, wwwadmin@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

This is what I did:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?patton\.example\.com
RewriteCond $1 !blog
RewriteRule (.*) /blog/$1 [L]

http://example.com/blog is the actual location.
http://blog.example.com is a working subdomain for the same location.
http://patton.example.com is the subdomain I want to rewrite to.

What can I do?

Thanks!

[edited by: jdMorgan at 3:57 pm (utc) on July 18, 2005]
[edit reason] Obscured specifics; please see TOS. [/edit]

jdMorgan

3:55 pm on Jul 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try adding:

Options +FollowSymLinks

ahead of your RewriteEngine on directive.

Whenever you get a server error, examine your server error log -- It will often tell you what the problem is. If you cannot access your error log, then you might want to get a new host, since debugging can be difficult without access to this important information.

Jim

rebayona

3:59 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Thanks again for your reply.

I did what you suggested and this is the result from the error log:

"File does not exist: /home/example/public_html/pat/blog/"

It seems that I'm getting closer...
I want to from /home/example/public_html/pat/ to /home/example/public_html/blog/

This is the current .htaccess file:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^(www\.)?pat\.example\.com
RewriteCond $1 !blog
RewriteRule (.*) http://example.com/blog/$1 [L]

(last line was RewriteRule (.*) /blog/$1 [L] as you suggested, but that was where I got the error)

And the current result:
When I enter http://pat.example.com
It does redirect to http://example.com/blog/
i want to get rid of the http://example.com/blog/ in the address bar, replacing it with http://pat.example.com

Thanks again!

[edited by: jdMorgan at 4:33 am (utc) on Sep. 2, 2005]
[edit reason] Obscured specifics per TOS. [/edit]

rebayona

9:11 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



I moved the nucleus instalation to the proper location and it worked. thanks for your support anyway.

Can I ask you a favor? Can you guys delete my previous post? There is some information there I don't want to be permanent or to be found through google, which I just did. I couldn't find a way to edit it

Thanks!