Forum

Thread tagged as: Question, Problem, Runway

Removing www from runway site

Hi all,

I used to use the below code to rewrite www. to non www (www.example.co.uk to example.co.uk), but in Perch Runway, it is causing some issues whereby example.co.uk works but www.example.co.uk gets redirected to example.co.uk/perch/core/runway/start.php (which states Sorry, that page could not be found.).

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
  RewriteRule (.*).xml(.*) $1.php$2 [nocase]
</IfModule>

Any ideas as to how I can achieve this in Runway? I figure it may have something to do with Routes?

Jon Young

Jon Young 0 points

  • 6 years ago

Jon. Here is one of my htaccess. It works the same when runway rewrite is added. Maybe it will help you.

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://domain.com/$1 [R=301,L]

# This rule will redirect users from their original location, to the same location but using HTTPS.
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]
Options -Indexes

Thanks for replying Robert. I'll try this when I get back to my PC :-)

Thanks again Robert, yours probably would have worked had I removed the https aspect, but in the end I ended up using a segment of my original code as below which seems to do the trick.

# Perch Runway
RewriteEngine On

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

RewriteCond %{REQUEST_URI} !^/perch 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /perch/core/runway/start.php [L]

Hi

I've used the .htaccess solution above, but it's logging me out of Perch Runway? .htacess rules are below.

I've done a quick 12 second screencast to show the problem: https://youtu.be/jwSdgTqMUXY

Here's what happens:

  1. I can login
  2. I can click around and save changes.
  3. When I click on the world icon a new tab opens and I can view the website
  4. I click back on the CMS tab, navigate to anything (a page, collection etc.)
  5. I get booted out?
  6. The URL looks strange:

      https://domain-name.co.uk/perch/?r=%2Fperch%2Fcore%2Fapps%2Fcontent%2F
    

Here's my htaccess

   # Perch Runway
   # RewriteEngine On
   # RewriteCond %{REQUEST_URI} !^/perch 
   # RewriteCond %{REQUEST_FILENAME} !-f
   # RewriteRule .* /perch/core/runway/start.php [L] 
   # I've only kept the original lines incase I need to revert.

   # Perch Runway
   RewriteEngine On

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

   RewriteCond %{REQUEST_URI} !^/perch 
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule .* /perch/core/runway/start.php [L]

Summary:

    Perch Runway: 2.8.4, PHP: 5.4.13, MySQL: 5.5.30, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.4), assets (2.8.4), categories (2.8.4), collection_1 (2.8.4), perch_blog (4.6), collection_4 (2.8.4), perch_forms (1.8.2), collection_3 (2.8.4), collection_5 (2.8.4)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/domain-name.co.uk/httpdocs/perch
PERCH_CORE: /var/www/vhosts/domain-name.co.uk/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/domain-name.co.uk/httpdocs/perch/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 8M, Memory: 128M, Total max file upload: 8M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /var/www/vhosts/domain-name.co.uk/httpdocs
HTTP_HOST: domain-name.co.uk