I'm pretty green with mod_rewrite. I've got the first line of this working like a champ, but the second part refuses to cooperate
RewriteRule ^(.*).html$ $1.php
RewriteRule ^(.*).shtml$ $1.php [R=301,L]
The .shtml part fails wonderfully and 404s - without my custom 404 page. Should this be combined in to one rule? Should I quit my job and let them hire a monkey to replace me? has anyone got a solution for this?
Thanks!
Assuming you are intending to redirect both .shtml and .html to .php...
These should both be combined into one rule, and the problem looks to be that both match because the unescaped . before .html stands for "any character", which therefore also matches shtml.
The pattern \.s?html will match the literal ., followed by an optional s, and ending with html.
RewriteEngine On
RewriteRule ^(.*)\.s?html$ $1.php [R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With