php user and SEO friendly URL

Viewed 32

I'm trying to change my default url with its parameter from

localhost/webiste/posts.php?name=what-is-btc 

to

 localhost/webiste/posts.php/what-is-btc 

I've tired to main htaccess code RewriteRule ^post([A-Za-z0-9-]+)/?$ post?name=$1 [NC]

But it's not working, can anyone please help me find a way to get it to work?

NB. I'm calling my data dynamically from database and I'm using php get to the name.

Thanks in advance.

1 Answers

You're missing the .php in your RewriteRule and also a leading slash.

Try this:

RewriteRule ^post/([A-Za-z0-9-]+?)/?$ /post.php?name=$1 [NC, L]
Related