Digital Point Forums
Wire Transfer

Go Back   Digital Point Forums > Design & Development > Site & Server Administration > Apache
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Mar 4th 2004, 2:00 pm
digitalpoint's Avatar
digitalpoint digitalpoint is offline
My cat is on Prozac... really. lol
 
Join Date: Mar 2004
Location: San Diego, California
Posts: 22,744
digitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond repute
Phone Verified
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>
What that will do is redirect any request within the domains defined in ServerAlias to the correct location within the main domain using a search engine friendly 301 redirection.

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.
Reply With Quote
  #2  
Old Jun 1st 2004, 3:43 pm
SEOGulper SEOGulper is offline
Peon
 
Join Date: Jun 2004
Posts: 18
SEOGulper is on a distinguished road
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?
Reply With Quote
  #3  
Old Jun 1st 2004, 3:50 pm
digitalpoint's Avatar
digitalpoint digitalpoint is offline
My cat is on Prozac... really. lol
 
Join Date: Mar 2004
Location: San Diego, California
Posts: 22,744
digitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond repute
Phone Verified
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.
Reply With Quote
  #4  
Old Jun 1st 2004, 9:30 pm
Owlcroft's Avatar
Owlcroft Owlcroft is offline
Twilight Vanquisher
 
Join Date: Mar 2004
Location: Ritzville, Washington, U.S.A.
Posts: 644
Owlcroft will become famous soon enough
Yes, you can.

Quote:
Can this be done with the htaccess file in the home directory of a shared server?
In a word, Yes.

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.com
RewriteRule ^(.*) http://seo-toys.com/$1 [L,R=301]
The 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)?$
!^www.yourdomain.com(: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.
Reply With Quote
  #5  
Old Jun 15th 2004, 1:54 am
al2six al2six is offline
Grunt
 
Join Date: Jun 2004
Posts: 53
al2six is on a distinguished road
Quote:
Originally Posted by Owlcroft
RewriteCond %{HTTP_HOST} www.seo-toys.com
RewriteRule ^(.*) http://seo-toys.com/$1 [L,R=301]
I want to use this on my shared server... are those two lines of code all I have to add to my .htaccess file? Or is there more? sorry for my ignorance, I've never really done much stuff like this
Reply With Quote
  #6  
Old Jun 15th 2004, 3:07 am
LucidNet LucidNet is offline
Grunt
 
Join Date: May 2004
Posts: 59
LucidNet is on a distinguished road
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
__________________
lucid dreaming
Dream ebooks
Reply With Quote
  #7  
Old Jun 15th 2004, 8:55 am
al2six al2six is offline
Grunt
 
Join Date: Jun 2004
Posts: 53
al2six is on a distinguished road
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?
Reply With Quote
  #8  
Old Jun 15th 2004, 9:06 am
T0PS3O's Avatar
T0PS3O T0PS3O is offline
Feel Good PLC
 
Join Date: Mar 2004
Location: 0101010101001011
Posts: 13,221
T0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond reputeT0PS3O has a reputation beyond repute
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! ->
Reply With Quote
  #9  
Old Jun 17th 2004, 12:40 am
al2six al2six is offline
Grunt
 
Join Date: Jun 2004
Posts: 53
al2six is on a distinguished road
Quote:
Originally Posted by al2six
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?
can anyone help?
Reply With Quote
  #10  
Old Jun 17th 2004, 2:35 am
john_loch's Avatar
john_loch john_loch is offline
Rodent Slayer
 
Join Date: Apr 2004
Posts: 1,281
john_loch has a spectacular aura aboutjohn_loch has a spectacular aura aboutjohn_loch has a spectacular aura about
Quote:
Originally Posted by al2six
can anyone help?
Remember to enable the rewrite engine in the first place.. (you'll notice the line in Shawns original post).. try:
--snip--
RewriteEngine on

RewriteCond %{HTTP_HOST} www.musicgearmaster.com
RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301]
--snip--

Cheers,
JL.
Reply With Quote
  #11  
Old Jun 17th 2004, 3:47 am
al2six al2six is offline
Grunt
 
Join Date: Jun 2004
Posts: 53
al2six is on a distinguished road
Quote:
Originally Posted by john_loch
Remember to enable the rewrite engine in the first place.. (you'll notice the line in Shawns original post).. try:
--snip--
RewriteEngine on

RewriteCond %{HTTP_HOST} www.musicgearmaster.com
RewriteRule ^(.*) http://musicgearmaster.com/reviews/drums/$1 [L,R=301]
--snip--

Cheers,
JL.
thanks! that worked. however it didn't do quite what I want it to do...
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?
Reply With Quote
  #12  
Old Jun 17th 2004, 8:33 am
digitalpoint's Avatar
digitalpoint digitalpoint is offline
My cat is on Prozac... really. lol
 
Join Date: Mar 2004
Location: San Diego, California
Posts: 22,744
digitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond reputedigitalpoint has a reputation beyond repute
Phone Verified
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.
Reply With Quote
  #13  
Old Jun 17th 2004, 11:56 am
al2six al2six is offline
Grunt
 
Join Date: Jun 2004
Posts: 53
al2six is on a distinguished road
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.
Reply With Quote
  #14  
Old Jun 21st 2004, 12:13 pm
flawebworks's Avatar
flawebworks flawebworks is offline
Tech Services
 
Join Date: Apr 2004
Location: here
Posts: 991
flawebworks will become famous soon enough
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
Reply With Quote
  #15  
Old Jun 21st 2004, 2:54 pm
flawebworks's Avatar
flawebworks flawebworks is offline
Tech Services
 
Join Date: Apr 2004
Location: here
Posts: 991
flawebworks will become famous soon enough
Got my answer:

forums.seochat.com/showthread.php?p=90130
Reply With Quote
  #16  
Old Aug 29th 2004, 7:16 pm
Will.Spencer's Avatar
Will.Spencer Will.Spencer is offline
NetBuilder
 
Join Date: Apr 2004
Location: Singapore
Posts: 11,911
Will.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond repute
Quote:
Originally Posted by digitalpoint
Code:
<VirtualHost 192.168.1.1>
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>
I made an error and only copied the 4 Rewrite lines, leaving off the ServerAlias line.

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]
Works just the same with the slightly different syntax.
Reply With Quote
  #17  
Old Mar 24th 2005, 12:21 pm
danpadams's Avatar
danpadams danpadams is offline
Champion of the Naaru
 
Join Date: Jan 2005
Posts: 101
danpadams is on a distinguished road
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?
__________________
Dan
infoChi Christian Computing - Concordance
Reply With Quote
  #18  
Old Nov 1st 2005, 10:05 pm
clasione clasione is offline
of the Nightfall
 
Join Date: Jan 2005
Location: Long Island
Posts: 2,348
clasione is a name known to allclasione is a name known to allclasione is a name known to allclasione is a name known to allclasione is a name known to allclasione is a name known to all
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
__________________
-
Reply With Quote
  #19  
Old Nov 2nd 2005, 12:02 am
Will.Spencer's Avatar
Will.Spencer Will.Spencer is offline
NetBuilder
 
Join Date: Apr 2004
Location: Singapore
Posts: 11,911
Will.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond reputeWill.Spencer has a reputation beyond repute
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/
Reply With Quote
  #20  
Old Nov 2nd 2005, 2:53 am
elrayjones elrayjones is offline
Grunt
 
Join Date: Nov 2005
Posts: 99
elrayjones is an unknown quantity at this point
Thanks this is just what I was looking for
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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


All times are GMT -8. The time now is 11:29 am.