PDA

View Full Version : Need assistance with a domain redirect.



SteveS
04-19-2011, 06:28 PM
I need some advise on redirecting from one (domain/directory) to another (domain) when the (domain/directory) and the (domain) point to the same directory on the server. I thought I would check here before opening a ticket.

The goal - Anytime anyone navigates to http://www.mydomain.com/forum/ I want them to be directed to http://forum.mydomain.com. I want to separately track traffic to the forum and the main pages of the site. I attempted to use the redirect wizard in cPanel but I received the following error.



Redirecting forum to http://forum.mydomain.com will cause a redirection loop because 'http://mydomain.com/forum'

which is located at /home3/mydirectory/public_html/mydomain/forum

is above 'http://forum.mydomain.com'

which is located at /home3/mydirectory/public_html/mydomain/forum


Domain mydomain.com points to /home3/mydirectory/public_html/mydomain

Domain forum.mydomain.com points to /home3/mydirectory/public_html/mydomain/forum

I am not in any way an apache expert, but it would seem that the following should work.



RewriteEngine on

RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^forum\/(.*)$ "http\:\/\/forum\.mydomain\.com" [R=301,L]


I was under the impression that apache looks at domains and then directories to take action and does not first translate everything to a full directory path to make a decision. I am aware that mod_rewrite can be used to direct someone to "www.adomain.com" when they attempt to navigate to just "adomain.com" and obviously both "www.adomain.com" and "adomain.com" point to the same directory.

Before I get crazy and attempt to manually modify the .htaccess file, I wanted some feedback.

Thanks,
Steve

Falcon1986
04-19-2011, 06:43 PM
Did you already properly set up the subdomain through cPanel, then install the forum software to it?

SteveS
04-19-2011, 06:57 PM
Did you already properly set up the subdomain through cPanel, then install the forum software to it?

Yes - The forum has been running OK for the past two years. It can be accessed via http://forum.mydomain.com or http://www.mydomain.com/forum. Using awstats I want to separately track access to the regular site, (http://www.mydomain.com) and the forum (http://www.mydomain.com/forum). Some users access the forum via URL (http://www.mydomain.com/forum) and other users access the forum via URL (http://forum.mydomain.com) so the stats are mixed. I want all access to the forum to be in one log and access to everything else (in the same domain) in another log.

This is the method I use for all of my other forums, but unfortunately, when I first published the URL for the forum I used http://www.mydomain.com/forum so 50% of the access is via this URL. The newer users use http://forum.mydomain.com since they are not aware of the other URL.

SteveS
04-20-2011, 06:47 AM
Did you already properly set up the subdomain through cPanel, then install the forum software to it?

Falcon1986,

I replied to your comment about an hour after you posted it but I received a message that it went into moderation. Please review and approve.