WebFaction
Community site: login faq

I'm having a bit of trouble setting up some redirect on one of my webfaction hosted sites. I'm trying to get a domain e.g.: http://www.example.com to redirect to http://example.com.

I have added the both domains to the same Static/CGI/PHP app and included the following in my webapps/app_name/.htaccess:

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

This seems to work, BUT if I go directly to a page, e.g.: http://www.example.com/page-1 it doesn't get redirected to http://example.com/page-1

Any ideas where I'm going wrong? I have tried several different rewrite conditions in the .htaccess file but none seem to redirect sub-pages?

Thanks for any help in advance!

asked 22 Jun '13, 13:56

lawlesscreation
2614
accept rate: 100%

edited 22 Jun '13, 14:11

I tried to reproduce the problem, but I was unable to find any URLs that behaved the way you described. Can you please do one of the following: 1) Tell me a specific 'www' URL that exhibits the problem, OR 2) Open a WebFaction Support ticket and tell me the details if you are not comfortable publishing the info on this public forum.

(22 Jun '13, 15:30) likebike
1

Also, I just wanted to mention that your redirect rules are not the first things in your .htaccess files, so if any of the top RewriteRules match the URL, processing will never make it to your 'www' redirect.

...If this doesn't help, tell me a specific URL so I can reproduce the problem.

(22 Jun '13, 15:33) likebike

Thanks for the help. I managed to fix it by moving the redirect to the top of my .htaccess file above WordPress' redirect rules and it worked!

Thanks for the tip!

(23 Jun '13, 05:53) lawlesscreation
Be the first one to answer this question!
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:

×75

question asked: 22 Jun '13, 13:56

question was seen: 3,060 times

last updated: 23 Jun '13, 05:53

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 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