MyBB Community Forums

Full Version: [advanced] URL Redirection Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
This will be an interesting question/challenge to anybody well-versed in the use of apache mod_rewrite on linux servers.

Background:
It is necessary for you to read this to understand the nature of my problem, goal, and question. I have heavily researched this topic before posting this thread (as heavily as possible for a newbie). On the type of server I use, you can not add a "www" prefix to a subdomain and you also can not use a-names or c-names to handle redirection via dns manager in the control panel. I have researched it EXTENSIVELY, if you want both sub.domain.com and www .sub.domain.com to point to the same directory, you must make two distinct subdomains both pointing to your content. Enter duplicate content problems...

-----------------------------------------------------

Goal:
My goal is for users to be able to search for or enter both the "www" and the "non-www" subdomain addresses into their browsers and be directed to my content. My fear is that because most people instinctively enter the www prefix before all addresses that users will think my content doesn't exist. So, since I am stuck with two distinct subdomains, I need a way to redirect all traffic to only one or risk duplicate content penalties.

-----------------------------------------------------

Directory Layout:

/domain/chat/index.html (subdomain #1)

/domain/non-www-chat/index.html (subdomain #2)

Both of these directories contain the exact same index.html page, which is nothing more than a simple html document using a 100% x 100% frame to link to a xat chatroom. The purpose is that members don't have to remember a long and convoluted address, they can simply go to chat . mysite . com.

-----------------------------------------------------

Current Setup:
The way I have it set up now, it is functioning perfectly and I really don't care about duplicate content issues as I have no concern with a chatroom being indexed by search engines, lol. However, as I continue to add content and subdomains, I will undoubtedly have to use this method again of creating both a "www" subdomain and a "non-www" subdomain to get the users to the same content.

------------------------------------------------------

The Million Dollar Question: How can I use .htaccess and url redirection to make users who type "subdomain.domain.com" into their browsers be automatically redirected to "www.subdomain.domain.com" ?????

(I have researched and tried several different angles with .htaccess unsuccessfully, although it seems this would have to be possible, I simply don't possess the skills to make it happen)
Couldn't you just use a redirect?
You could use A 301 redirect in HTACCESS, redirect using HTML, or even redirect using php. Have you tried these? If not I can try to explain them to me
(2010-12-13, 06:30 PM)UndiscoveredTalent Wrote: [ -> ]Couldn't you just use a redirect?

I've yet to find one that works. That's what I am asking for, a proper redirect. Big Grin
(2010-12-13, 06:33 PM)Tom K. Wrote: [ -> ]You could use A 301 redirect in HTACCESS, redirect using HTML, or even redirect using php. Have you tried these? If not I can try to explain them to me

As explained in my post above in great detail, I have tried. But I can't get it to work. That is why I am hopeful that someone, with the info and details I've provided, could give me a sample one that would work. Big Grin

* Another question, does a directory being redirected via a .htaccess file need to possess an index page in it?
Well you could try PHP.

Make a page named index.php, in it put:
<?
echo "Redirecting to Chat";
header("Location: http://www.chat.yourdomain.com");
?>
i know search engines frown on using meta-refresh in a .html document, how do they feel about using the sort of redirect you just showed using php?

you will deserve 10,000 rep points! Big Grin

* my ultimate goal was for this to be done invisibly server side for SEO reasons... because eventually i will probably use this method for other subdomains (that are more important to be indexed)
To be honest, 1 page redirecting won't make much different. But to be completely safe you should use a 301 redirect.

Make a file named htaccess.txt containing:
redirect 301 http://chat.yourdomain.com http://www.chat.yourdomain.com/

Upload it to your /chat directory and rename it to .htaccess Smile
hmmmm...

i'm used to seeing .htaccess files that start with:

Options +FollowSymlinks
RewriteEngine On

and have all sorts of $ and ^

Big Grin
Ok try this too:
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^chat.yoursite.com [NC] 
RewriteRule ^(.*)$ http://www.chat.yoursite.com/$1 [L,R=301] 
yep, tried it. it goes right around it. and load the non-www page.

it's the weirdest thing.

* that's why i was wondering if this was an issue with the fact that the subdomains are already a sort of redirect from actual directories...

if you are interested in seeing this happening. you can go to the webpage in question,

http://www.chat.thelonelylife.com/
http://chat.thelonelylife.com/

htaccess is up and running at this time, but i don't see it redirecting
Pages: 1 2 3