![]() |
|
|
#1
|
||||
|
||||
|
Multiple Domains...
Here's a little tip for people using Apache with multiple domains pointed to a single site (even if it's just www.yourdomain.com and yourdomain.com). This can be used within your apache (or site) conf file on the server (changing the items to work with your domain/IP address of course).
Code:
<VirtualHost 192.168.1.1> ServerName www.yourdomain.com ServerAlias www.anotherdomain.com yourdomain.com RewriteEngine on RewriteCond %{HTTP_HOST} !^192.168.1.1(:80)?$ RewriteCond %{HTTP_HOST} !^www.yourdomain.com(:80)?$ RewriteRule ^/(.*) http://www.yourdomain.com/$1 [L,R=301] </VirtualHost> This is nice because you don't have to have tons of rewrites, and it also makes search engines happy because you aren't replicating content. - Shawn
__________________
~ Shawn @Twitter Keyword Tracker Please do not PM, IM or email me for product or tool support (they will go unread/ignored), and don't "friend" me unless we are really friends. |
|
#2
|
|||
|
|||
|
So... what if we are on a shared server, and have no access to the config file or the root directory?
Can this be done with the htaccess file in the home directory of a shared server? |
|
#3
|
||||
|
||||
|
Yes, you should be able to do it within the .htaccess file as well. Although I've never done it at that level myself, so I can't offer an example. But pretty much if you just use the RewriteCond and RewriteRule lines, I think you would be okay.
__________________
~ Shawn @Twitter Keyword Tracker Please do not PM, IM or email me for product or tool support (they will go unread/ignored), and don't "friend" me unless we are really friends. |
|
#4
|
||||
|
||||
|
Yes, you can.
Quote:
My own local .htaccess files deal with a more restricted case, that of just the presence or absence of the leading "www.". They typically look like this: RewriteCond %{HTTP_HOST} www.seo-toys.comThe ones presented in the post above are more general in scope, and essentially, as I understand it, redirect any call that is not exactly what you want to the one that is exactly what you want. That is, the conditions-- !^192.168.1.1(:80)?$--specify that anything that is not Port 80 on either 192.168.1.1 or www.yourdomain.com is something to rewrite to: http://www.yourdomain.com/$1(where the $ stuff means plug in whatever follows).
__________________
Cordially, Eric Walker SEO Tools, Toys, and Packages: free tools to augment your sites: for example, quickly add over 100,000 white-hat pages to any site. |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
|||
|
|||
|
i have access to my conf file but have already done the htaccess redirection instead?
Would you say it is better for me to move the redirection to the conf file? and why? al2six.... i just did that to my htaccess and it worked fine. Just them two lines of code |
|
#7
|
|||
|
|||
|
It doesn't seem to be working for me...
Here is the entire contents of my htaccess file: RewriteCond %{HTTP_HOST} www.musicgearmaster.com RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301] It should take you to the nonexistant folder reviews/drums but it still just takes you to the index page. Any ideas why it isn't working? |
|
#8
|
||||
|
||||
|
typo
We have two domains per site, one is our own URL and one is a subfolder of the big shopping portal who provide our ecommerce solution. I get the impression (Shawn's Tool confirms it) that Google likes the pages in the subfolder better than those in our own URL.
Is there any reason why Google would prefer pages from a domain with thousands of pages over the exact same page on a domain with just a few hundred? Amazon seems to appear in a lot of top 10 listings, does G take website size into account when it comes to calculating SERPs? I'm debating which one to choose if we do want to redirect the other... Any ideas?
__________________
Try: Sell Your Ad Space - Thousands Of Visitors Want To Buy Your Ad Space Global Internet Index Directory <- Check it out! -> |
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
||||
|
||||
|
Quote:
--snip-- RewriteEngine on RewriteCond %{HTTP_HOST} www.musicgearmaster.com RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301] --snip-- Cheers, JL.
|
|
#11
|
|||
|
|||
|
Quote:
I have more than one domain on that server. Each domain is for a seperate site and should point to a folder containing the content for that site. so when you type in www.musicgearmaster.com, i want it to take you to www.musicgearmaster.com/reviews/index.php. But if i use the following... RewriteCond %{HTTP_HOST} www.musicgearmaster.com RewriteRule ^(.*) http://musicgearmaster.com/reviews/$1 [L,R=301] Then if you type in the exact filename of a page (ie www.musicgearmaster.com/reviews/index.php) it will try to take you to www.musicgearmaster.com/reviews/reviews/index.php anyone have a solution for this? |
|
#12
|
||||
|
||||
|
Take off the "reviews/" part of your RewriteRule.
__________________
~ Shawn @Twitter Keyword Tracker Please do not PM, IM or email me for product or tool support (they will go unread/ignored), and don't "friend" me unless we are really friends. |
|
#13
|
|||
|
|||
|
But the index page for the site is in the reviews folder. If I take off the reviews, when you type in the domain, it will take you to index.php (which is the index for another site on the server) instead of reviews/index.php which is the correct index page.
|
|
#14
|
||||
|
||||
|
Will doing this; as you demonstrate:
RewriteCond %{HTTP_HOST} www.seo-toys.com RewriteRule ^(.*) http://seo-toys.com/$1 [L,R=301] Cause google to change any backlinks going to www to end up with the non-www backlinks it has picked up? Do I even make sense?:O In other words: the majority of my backlinks go to domainname.com as opposed to www.domainname.com - I have 5 or 6 strays that I would really like to show up under the domainname.com backlinks. Thanks for the above string. I've been trying for 2 days to get a 301 redirect to work the way I want it to. Regards; Flawebworks |
|
#15
|
||||
|
||||
|
Got my answer:
forums.seochat.com/showthread.php?p=90130 |
|
#16
|
||||
|
||||
|
Quote:
I already had a similar ServerAlias line, but one with only one argument in it. I also have a ServerName line. My code, therefore, looks like this: Code:
ServerName www.internet-search-engines-faq.com
ServerAlias internet-search-engines-faq.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^216.17.194.115(:80)?$
RewriteCond %{HTTP_HOST} !^www.internet-search-engines-faq.com(:80)?$
RewriteRule ^/(.*) http://www.internet-search-engines-faq.com/$1 [L,R=301]
__________________
|
|
#17
|
||||
|
||||
|
Will,
Is the second version of the code you last posted in this thread the .htaccess equivalent of the code above that would be from an httpd.conf file? |
|
#18
|
|||
|
|||
|
ok - I can't seem to get this to work......
Give me an example based on the following senario.... All pages of .net are moving to .com So I need an example using all pages of: www.from.net from.net redirect to: www.destination.com
__________________
- |
|
#19
|
||||
|
||||
|
Heck, this is more complex than you need for that.
Just put this one line in the .htaccess file for your .net domain: Code:
Redirect 301 / http://www.destination.com/
__________________
|
|
#20
|
|||
|
|||
|
Thanks this is just what I was looking for
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IP adress question | rwhetsto | Search Engine Optimization | 25 | Apr 1st 2008 11:37 pm |
| getting our old domains back? | disgust | Site & Server Administration | 5 | Jan 7th 2006 9:15 pm |
| Third level domains...... | NewComputer | Search Engine Optimization | 1 | Jun 10th 2004 8:48 am |
| multiple themed reciprocal links between two domains | Headward | Link Development | 1 | Jun 10th 2004 2:26 am |
| Linking Advice | theblade24 | Link Development | 5 | May 1st 2004 11:31 am |