• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Pretty URLs not working after switching to HTTPS
PostPosted: Thu Sep 14, 2017 2:56 am 
Offline
Power Poster
Power Poster

Joined: Mon Mar 14, 2011 1:16 am
Posts: 266
Location: Brisbane, Australia
We've just migrated a website from HTTP to HTTPS, and taken care of all of the fundamental steps (as per below), however pretty URLs no longer work. For example:

This: https://www.gallangplace.org.au/index.php?page=services
Should be: https://www.gallangplace.org.au/services

The steps we followed were:

* Updating all domain references from http:// to https:// in files and the database (including serialised arrays)
* Specifying the HTTPS address etc in config.php
* Clearing all caches, updating routes and hierarchies etc
* Updating .htaccess to redirect from HTTP to HTTPS with wildcards

We've done this countless times on various websites, but this is the first CMS Made Simple website, and we have more to go.

Any suggestions would be greatly appreciated.

Here's our .htaccess file:

Code:
############ FILE LISTINGS ############

Options -Indexes

<Files "config.php">
order allow,deny
deny from all
</Files>

############ ERROR HANDLING ############

ErrorDocument 403 /forbidden403.shtml

ServerSignature Off

############ OPTIMISATION ############

# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# compress css, text...
<FilesMatch "\.(js|css|html|htm|php|xml|htc|eot)$">
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
</FilesMatch>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript image/gif text/x-js application/javascript image/x-icon
</IfModule>

# set expires headers
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
  ExpiresByType text/x-component "access plus 1 years 1 days"
</ifModule>

<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|ttf|eot|woff|svg)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js|htc)$">
    Header set Cache-Control "max-age=216000, private"
  </filesMatch>
  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"
  </filesMatch>
  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"
  </filesMatch>
</ifModule>

# enable gzip
<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl|htc|eot|ttf|woff|svg|ico|pdf|flv)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

# disable ETags
<ifModule mod_headers.c>
  Header unset ETag
</ifModule>
  FileETag None

<ifModule mod_headers.c>
  Header unset Last-Modified
</ifModule>

#
# The following is to enable pretty URLs, only applicable if url_rewriting is set to 'mod_rewrite' in the config.php
#
<IfModule rewrite_module>
  RewriteEngine on
  # If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.
  # In example: RewriteBase /[subdirectory name]
  #RewriteBase /

# +++++ ADD THIS - START +++++
  # Link to http(s)://website... then redirect to https://www.website...
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

  # Force URLs have https instead of http
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# +++++ ADD THIS - END +++++

# Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
  RewriteCond %{REQUEST_FILENAME} !-f [NC]
  RewriteCond %{REQUEST_FILENAME} !-d [NC]
  RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

RewriteCond %{HTTP_HOST} ^gallangplace\.org\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.gallangplace\.org\.au$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ "https\:\/\/www\.gallangplace\.org\.au\/$1" [R=301,L]


And here's our config.php file:

Code:
<?php

$config['ssl_url'] = 'https://www.gallangplace.org.au';
$config['root_url'] = 'https://www.gallangplace.org.au';
$config['admin_url'] = 'https://www.gallangplace.org.au/admin';

# DATABASE
$config['db_hostname'] = 'xxxxxxxxxxxxxxxx';
$config['db_username'] = 'xxxxxxxxxxxxxxxx';
$config['db_password'] = 'xxxxxxxxxxxxxxxx';
$config['db_name'] = 'xxxxxxxxxxxxxxxx';
$config['db_prefix'] = 'xxxxxxxxxxxxxxxx';
$config['dbms'] = 'mysqli';

# PRETTY URLS
$config['url_rewriting'] = 'mod_rewrite';
$config['query_var'] = 'page';
$config['internal_pretty_urls'] = true;
$config['assume_mod_rewrite'] = true;
$config['use_hierarchy'] = true;

# SERVER SETTINGS
$config['timezone'] = 'Australia/Brisbane';
$config['default_upload_permission'] = '777';
$config['debug'] = false;
?>


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URLs not working after switching to HTTPS
PostPosted: Thu Sep 14, 2017 8:02 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Dec 09, 2005 12:36 pm
Posts: 218
Location: Marlow, UK
It's early in the morning here for trying to work out rewrite rules (and I've not had coffee) but I think that the last redirect is your problem.

So this rule

Code:
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

is rewriting the url but then after that you have this rule:

Code:
RewriteCond %{HTTP_HOST} ^gallangplace\.org\.au$
...
RewriteRule ^(.*)$ "https\:\/\/www\.gallangplace\.org\.au\/$1" [R=301,L]

which is redirecting the page using the url that was previously rewritten.

I'm not entirely sure what that last block of code is doing so you could either try removing it if you don't have a good reason for it, or move the rewrite rule to be the final thing in the htaccess file.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Pretty URLs not working after switching to HTTPS
PostPosted: Thu Sep 14, 2017 8:19 am 
Offline
Power Poster
Power Poster

Joined: Mon Mar 14, 2011 1:16 am
Posts: 266
Location: Brisbane, Australia
Thanks! I swear I moved/deleted that block a million times. I really appreciate the fresh eyes.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
HostPapa CMS Made Simple hosting