Forum
Non-www redirect going to wrong URL
Hi,
I'm having a problem with redirecting my non-www domain to the www.coconutstrategy.com domain which I hope you might see an easy fix for. At the moment https://coconuststrategy.com is redirecting to: https://www.coconutstrategy.com/perch/core/runway/start.php which is causing a 404 Error to appear. My rewrite rules are thus:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^coconut-group.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.coconut-group.com [NC]
RewriteRule ^(.*)$ https://www.coconutstrategy.com/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301]
RewriteCond %{REQUEST_URI} !^/perch
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /perch/core/runway/start.php [L]
</IfModule>
here is my diagnostic report:
Perch Runway: 2.8.7, PHP: 5.6.8, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.7), assets (2.8.7), categories (2.8.7), perch_blog (4.6), perch_forms (1.8.3), collection_1 (2.8.7), perch_twitter (3.5.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_twitter' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/c/coconutstrategy.com/public_html/perch
PERCH_CORE: /var/sites/c/coconutstrategy.com/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/c/coconutstrategy.com/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/w/www.coconutstrategy.com/public_html
HTTP_HOST: www.coconutstrategy.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Have you tested the Runway rewrite rules without your additions?
Yes, it still does the same thing unfortunately!
Sorry, the same thing being what?
The non-www domain redirects to https://www.coconutstrategy.com/perch/core/runway/start.php which produces a 404 error.
Does the correct domain work as you'd expect?
Yes it works absolutely fine. I've actually put a domain redirect in for the time being as a workaround. Typically I've used a 301 redirect in the past at site level but the www sub domain should work, does this mean perch doesn't support sub domains?
No, it's nothing to do with Perch really - just a case of getting the right incantation in place for mod_rewrite.
I'll do some reading and see what I can find.
Can you try adding an
L
to this: