WebFaction
Community site: login faq

is there a definitive, more generic way to redirect from a www request to nowww than what's on WF documentation here: http://docs.webfaction.com/software/static.html#redirect-a-domain-with-a-static-cgi-php-app ?

asked 14 Dec '10, 13:53

htrex
51129
accept rate: 0%


yes! found here http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www maybe the docs could be enhanced too with this little magic definitive rule :)

permanent link

answered 14 Dec '10, 13:55

htrex
51129
accept rate: 0%

It is hard to document .htaccess rules in depth since they are complex, It is easier to address them on a per-case basis.

(14 Dec '10, 14:38) johns ♦♦

Thanks htrex - was looking for this here.

(20 Dec '12, 03:35) epqrs

Hi Team,

I had similar issue so things didn't work with these codes earlier. I referred few notes from Richbeales.net's blog, and webfaction docs, and few other blogs too. Mostly I feel the issue is with providing followsymlinks Hence I recognize few things,so I followed this steps when trying to redirect www.example.com to example.com. Hope you get solution through this notes.

In the control panel: Create a new application as "serverredirectedto, using "new Static/CGI/PHP-5.x" If you find www sites in any of the single sites you created earlier in "websites tab" in the webfaction control panel, remove the www domain from each of them Create a new website, call it "serverredirect", add ALL the www domains to it, and point it to the "serverredirectedto" application Save it

SSH into your server, (Kindly read about SSH after this solution works to know more about it) If someone doesn't yet know about SSH. It is Secure Shell. Secure way to log into to a remote machine which have a server software maintaining your apps and ssh provide you option to direct provide codes or applying changes without allowing others to check what you useful data. So open your terminal. And type ssh "username"@"host".webfaction.com mostly username will the one which you use to log into the webfaction dashboard. i.e., my.webfaction.com and it will pop up asking your password. Than it shows ["username"@"host" ~]$

and: cd /yourusername/webapps/serverredirectedto vi .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NC]

And save and exit

If you want to reverse, per say example.com to www.example.com, do the opposite way by providing codes as

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^origin_domain$ [NC]
RewriteRule ^(.*)$ http://destination_domain/$1 [R=301,L]

Have fun..

permanent link

answered 12 Mar '14, 06:14

Rohith Kumar
11
accept rate: 0%

edited 12 Mar '14, 06:31

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×74
×1

question asked: 14 Dec '10, 13:53

question was seen: 6,341 times

last updated: 12 Mar '14, 06:31

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM