Forum

Thread tagged as: Question, Blog

Blog URL rewriting not working

I'm trying to rewrite /blog/post.php?s={postSlug} to /blog/{postSlug} but I just get a 404. I tried about every combination I can think of to get it to work but no joy.

My .htaccess file looks like this, with some rewrites to also remove the extension and force https. I've also tried removing all the extra rewrite stuff and just use the line for rewriting blog post urls, and that doesn't work either, just 404's. What am I doing wrong?

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]s

</IfModule>
Chad Tiffin

Chad Tiffin 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm sure someone might have a suggestion for you in the morning, but otherwise a site like Stack Overflow might be a good place for general URL rewriting questions.