Search code examples
apache.htaccessqsa

htaccess using QSA returning 404


I'm trying to direct a url for a blog post to a PHP page that takes a GET var using htaccess.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/post/(\w+)$ blog/post.php?title=$1 [QSA,L]

However, this just gives me a 404. I have confirmed that /blog/post.php?title=my-postis a valid url.


Solution

  • Since your title contains hyphens your rule should allow it:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^blog/post/([\w-]+)$ blog/post.php?title=$1 [QSA,L,NC]