Forum

Thread tagged as: Problem, Runway, Shop

www. to non-www. redirect not working for Perch Shop Products

Hi

We have a www. to non-www. redirect setup in .htaccess which works great with normal pages.

However for Shop Product URLs if you try to go to the www. version we get a 404 not found error (go to the non-www. URL and it works)

So...

https://domain.com/product/{slug} = works

https://www.domain.com/product/{slug} = 404 error

In Shop Settings the Live site URL is set to blank and the Product URL is set to /product/{slug}.

What am I missing to make the www. redirect to the non-www. for Perch Shop Products work?

Many thanks

Perch Runway: 2.8.34, PHP: 5.6.25, MySQL: 5.6.33, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3), perch_shop_orders (1.0.10), perch_shop_products (1.0.10), collection_2 (2.8.34), perch_shop (1.0.10), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /cms
PERCH_PATH: /home/cvia/K5E8866U/htdocs/cms
PERCH_CORE: /home/cvia/K5E8866U/htdocs/cms/core
PERCH_RESFILEPATH: /home/cvia/K5E8866U/htdocs/cms/resources
Image manipulation: GD Imagick
PHP limits: Max upload 128M, Max POST 128M, Memory: 256M, Total max file upload: 128M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: cvandinterviewadvisors.co.uk
DOCUMENT_ROOT: /home/cvia/K5E8866U/htdocs/
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
Glen Piggott

Glen Piggott 0 points

  • 4 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

I am going to go out on a limb and say it's probably the .htaccess rewrite that is causing the issue - at a guess, does the matching rule include dashes? It might be a character in the slug that isn't being matched in the rule and so no rewrite occurs.

Just a guess.

A wild guess...

Duncan Revell said:

I am going to go out on a limb and say it's probably the .htaccess rewrite that is causing the issue - at a guess, does the matching rule include dashes? It might be a character in the slug that isn't being matched in the rule and so no rewrite occurs.

Just a guess.

A wild guess...

Thanks for the quick response Duncan.

the .htaccess looks like this...

<IfModule mod_rewrite.c>
RewriteEngine On


# REDIRECT MULTIPLE DOMAINS TO MAIN DOMAIN
    Options +FollowSymLinks
    RewriteCond %{HTTP_HOST} ^cvia.dns-systems.net$ [OR]
    RewriteCond %{HTTP_HOST} ^www.thecvandinterviewadvisors.com$ [OR]
    RewriteCond %{HTTP_HOST} ^thecvandinterviewadvisors.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.thecvandinterviewadvisors.co.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^thecvandinterviewadvisors.co.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www.cvandinterviewadvisors.com$ [OR]
    RewriteCond %{HTTP_HOST} ^cvandinterviewadvisors.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.cvandinterviewadvisors.co.uk$
    RewriteRule ^(.*)$ https://cvandinterviewadvisors.co.uk/$1 [R=301,L]


# REDIRECT NON-HTTP TO HTTPS
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]



# PERCH CLEAN BLOG URLs
    RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
    RewriteRule ^uploads/cv/(.*)$ /downloadSF.php?f=$1 [L]

#301
    RewriteRule ^([a-z\-]{2,})/index$ /$1 [R=301,L]

# REMOVE FILE EXTENSION FROM URL
# e.g. example.com/page will display the contents of example.com/page.php
    RewriteCond %{REQUEST_URI} !^/cms
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule .* /cms/core/runway/start.php [L]
    #RewriteRule ^(.+)$ $1.php [L,QSA]
</IfModule>
Duncan Revell

Duncan Revell 78 points
Registered Developer

So much for wild guesses.

I'm as stumped as you - I'm not sure why that wouldn't be working...!