
![]() |
jsp123
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
![]() Here is what I found: RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*).domain.com$ RewriteCond %{HTTP_HOST} !^www.domain.com$ RewriteRule (.*) http://domain.com/%1$1 <> and here it is in my htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} ^(.*).MYdomain.com$ RewriteCond %{HTTP_HOST} !^www.MYdomain.com$ RewriteRule (.*) http://MYdomain.com/%1$1 <> RewriteRule ^dating/([^/.]+)/([^/.]*)/([^/.]*)/([^/.]*)/?([^/.]*)?/? page. php?id=$4 <>RewriteRule ^images/girls/([^/.]+)/([^/.]*).jpg /images/girls/$1.jpg <> Any pointers? Thanks! jsp123 m0nkeymafia
its canonicalization [spelling] google it youll find what you need mate
perkiset
Two ways to do it mate...
Either alias the server if you dont care ie., ServerName www.adomain.com ServerAlias adomain.com or even ServerAlias *.adomain.com Or a rewrite to the domain you want to go to: <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> m0nkeymafia
perk i do it like this, is your way better?
RewriteCond %{HTTP_HOST} ^www.xxx.com RewriteRule (.*) http://xxx.com/$1 [R=301,L] fyi that rewrites www.xxx.com to xxx.com perkiset
quote author=m0nkeymafia link=topic=492.msg3185#msg3185 date=1189368832 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: 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 <> 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 workApachedoes.![]() /p m0nkeymafia
nice one p daddy
<noob>i have a vps but dunno where my httpd.conf is...where can i find it?</noob> ![]() perkiset
usually /user/local/
apache2/confyou'll find lots of interesting things there ![]() 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/*.incso I can have a different file for each site. then use /usr/local/ apache2/bin/apachectl -k gracefuland 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 apacheand <that> config is no longer valid. What I like about this, rather than .htaccess, is that all of myApachestuff 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 m0nkeymafia
hmm im not sure where to actually get to the htaccess :/
man im so lame with vps' lol perkiset
.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. m0nkeymafia
woops i mean httpd.conf lol
Bompa
quote author=m0nkeymafia link=topic=492.msg3210#msg3210 date=1189449385 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 perkiset
Which is good because we miss you
![]() |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads