The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 12:56:07 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Domain Concatenation with htaccess?  (Read 5457 times)
jsp123
Rookie
**
Offline Offline

Posts: 20


View Profile
« on: September 07, 2007, 12:51:44 PM »

Sorry, I am curious how to make www.sitename.com automatically be sitename.com(no matter the folder it is requesting)... I found something on google but it doesn't seem to work Smiley

Here is what I found:

Code:
RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ RewriteCond %{HTTP_HOST} !^www\.domain\.com$ RewriteRule (.*) http://domain.com/%1$1 [P]

and here it is in my htaccess:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.MYdomain\.com$ RewriteCond %{HTTP_HOST} !^www\.MYdomain\.com$ RewriteRule (.*) http://MYdomain.com/%1$1 [P]
RewriteRule ^dating/([^/\.]+)/([^/\.]*)/([^/\.]*)/([^/\.]*)/?([^/\.]*)?/? page.php?id=$4 [L]
RewriteRule ^images/girls/([^/\.]+)/([^/\.]*).jpg /images/girls/$1.jpg [L]

Any pointers?

Thanks!

jsp123
Logged

No links in signatures please
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #1 on: September 07, 2007, 02:58:22 PM »

its canonicalization [spelling] google it youll find what you need mate
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: September 09, 2007, 12:52:51 PM »

Two ways to do it mate...

Either alias the server if you dont care ie.,
Code:
ServerName  www.adomain.com
ServerAlias   adomain.com

or even

ServerAlias *.adomain.com

Or a rewrite to the domain you want to go to:
Code:
<VirtualHost 1.2.3.4:80>
        ServerName      www.adomain.com
        ServerAlias     www.adomain.org
        ServerAlias     a-domain.com
        DocumentRoot   /adir/
        RewriteEngine   on
        RewriteRule     ^(.*)$  http://adomain.com$1
</VirtualHost>
<VirtualHost 1.2.3.4:80>
        ServerName      adomain.com
        DocumentRoot   /adir/
</VirtualHost>
« Last Edit: September 09, 2007, 12:54:41 PM by perkiset » Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #3 on: September 09, 2007, 01:13:52 PM »

perk i do it like this, is your way better?

Code:
RewriteCond %{HTTP_HOST} ^www.xxx.com
RewriteRule (.*) http://xxx.com/$1 [R=301,L]

fyi that rewrites www.xxx.com to xxx.com
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: September 09, 2007, 01:31:04 PM »

perk i do it like this, is your way better?
Dunno about better, just a different way - probably exactly the same speed.

The difference here is that you are obviously more familiar with working simply in the .htaccess portion and I am more familiar with working 100% in the httpd.conf - I rarely use .htaccess. I do an include for all my sites so I can wrap all the control up in one place.

This code:
Code:
RewriteCond %{HTTP_HOST} ^www.xxx.com
RewriteRule (.*) http://xxx.com/$1 [R=301,L]

looks to be set so that any request to *xxx.com would be routed into <this directory> - so you want to 301 them to the correct place. The [L] is somewhat redundant because that is, in fact, the last rewrite to lookat (unless it's not, and if you're using this as a fragment of the .htaccess then that makes sense).

My snippet assumes that I'll have one virtual host section for the site I actually want to work with, and another for everything that I want to bounce. From a processing perspective, IME, the more rewrite directives I have for every page pull the more work I throw at Apache... so I'll weight the processor load towards the bounce, since this will one pull per surfer... rather than checking the mod_rewrite rules for every single call. Bear in mind, that even graphics, js, css calls will get thrown through this filter, so the fewer evals you can do per call the less work Apache does.


/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #5 on: September 10, 2007, 01:33:17 AM »

nice one p daddy

<noob>i have a vps but dunno where my httpd.conf is...where can i find it?</noob>

 Praise
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: September 10, 2007, 06:48:47 AM »

usually /user/local/apache2/conf

you'll find lots of interesting things there Wink

I create a directory below that, /sitefiles, where I put snippets of a config ie., thisdomain.inc, thatdomain.inc - and then I put an include into httpd.conf like

Include /usr/local/apache2/conf/sitefiles/*.inc

so I can have a different file for each site. then use

/usr/local/apache2/bin/apachectl -k graceful

and each current child process will be allowed to die off as they complete their current load, being replace by a new one that is on the new configuration. You can then simply change adomain.inc to adomain.bkp or something and restart apache and <that> config is no longer valid. What I like about this, rather than .htaccess, is that all of my Apache stuff is centralized and easy to see - rather than distributed all over my system. There is definitely a time and place for .htaccess, but I use it as sparingly as possible.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #7 on: September 10, 2007, 11:36:25 AM »

hmm im not sure where to actually get to the htaccess :/
man im so lame with vps' lol
Logged

I am Tyler Durden
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: September 10, 2007, 12:34:10 PM »

.htaccess will be in each directoy you want to affect ie., if you have a website that the DocumentRoot is

/www/sites/adomain/

then .htaccess would live there and affect everything in that directory *and below* provided there is not another .htaccess in a lower directory that modifies the "upper" htaccess effects. Note that since the filename is DOT htaccess (.htaccess) you will not be able to see it with a simple ls- l ... you will need to ls -la. It is editable, however, by any standard means like vi.

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
m0nkeymafia
Expert
****
Offline Offline

Posts: 240


Check it!


View Profile
« Reply #9 on: September 11, 2007, 02:58:03 AM »

woops i mean httpd.conf lol
Logged

I am Tyler Durden
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #10 on: September 11, 2007, 03:23:28 AM »

hmm im not sure where to actually get to the htaccess :/
man im so lame with vps' lol


I am a vps noob also and dont even have one atm, but those files should be editable
from the control panel, like Click To Edit type of thing.

(i dunno really, just looking for a thread to post in)  lol
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #11 on: September 11, 2007, 07:16:06 AM »

Which is good because we miss you  Wink
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!