I’m currently attempting to rewrite URLS for my employer’s website for hopefully better results in SEO. However, I can’t seem to get the url rewrite to work.
I have used this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myemployerssite.com.au$
RewriteRule (.*) https://www.myemployerssite.com.au/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ErrorDocument 404 https://www.myemployerssite.com.au/page-not-found.php
RewriteRule ^services/civil-construction$ /services.php?serviceid=1 [L]
</IfModule>
I expected, for example, the first service page which is civil construction to have it’s URL to be rewritten from https://www.myemployerssite.com.au/services.php?serviceid=1 to https://www.myemployerssite.com.au/services/civil-construction
But the URL remains as https://www.myemployerssite.com.au/services.php?serviceid=1
The redirect from non-www to www is working as intended as is the redirect from to http to https.
Some advice would be appreciated
2
Answers
I changed the order of the rules:
Try changing this line
to