Forum
Runway Rewrite Rules for SEO
Hi,
I am trying to achieve three goals with my htaccess rules.
- Force https://
- Force either https://www.sitename.co.uk or https://sitename.co.uk (doesn't matter which, just as long as one has a preference
- Force a trailing slash on urls, for example, https://sitename.co.uk/
Currently, my htaccess file looks like this:
# Perch Runway
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/deliberately-removed
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /deliberately-removed/core/runway/start.php [L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Forcing https seems sucessful with this rule.
https://moz.com/blog/htaccess-file-snippets-for-seos recommends the following for forcing www and adding a trailing slash
# Ensure www on all URLs.
RewriteCond %{HTTP_HOST} ^website-url.co.uk [NC]
RewriteRule ^(.*)$ https://www.website-url.co.uk/$1 [L,R=301]
# Ensure all URLs have a trailing slash.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://www.website-url.co.uk/$1/ [L,R=301]
However, adding these seems to result in the site just being redirected to https://transition-creative.co.uk/ouvrir/core/runway/start.php, obviously not the desired result.
Some pointers on resolving the above would be very much appreciated.
I think you probably want your 301 redirects to happen first. Put the default rewrite to
start.php
at the end of the process.Thanks Drew,
This was pretty successful apart from one error. As you suggested I changed the order to the following:
This works as disired until I request https://transition-creative.co.uk, this is forced to https://transition-creative.co.uk/ouvrir/core/runway/start.php
Hi all,
I thought I had the above working, but it has a rather nasty side effect. As a result of the above. No forms can be submitted and shop items cannot be purchased?
So I've had to revert to the original until I can find an alternative.
Check the
action
attribute on the forms and make sure that they're posting to a URL that isn't redirected. If a redirect occurs after the post, the post data will be lost.Thanks Drew, I'll look into it.