Reputation: 49
I'm trying to make a url rewrite to a page, where it should find a hashtag.
RewriteEngine On
RewriteRule ^/posts/hashtag/([a-zA-Z0-9_-]+)$ index.php?url=posts&hashtag=$1
But this way does not seem to work. e.g. if the value $1 is funny, the output should be domain.com/posts/hashtag/funny but it's not.
Upvotes: 3
Views: 186
Reputation: 7476
Try it like this, when you put url domain.com/posts/hashtag/funny
in your browser it will rewritten to index.php?url=posts&hashtag=$1
internally.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^posts/hashtag/([\w-]+)$ index.php?url=posts&hashtag=$1 [QSA,L]
Upvotes: 1