1

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.

iroro
  • 11
  • 2
  • Does this answer your question? [using seo user friendly in php](https://stackoverflow.com/questions/1444151/using-seo-user-friendly-in-php) – matronator Sep 11 '22 at 06:27
  • Hi @matronator that's kinda what I was looking for, but that didn't answer my Q. I've also checked others but none are working, + I've updated the question here. – iroro Sep 12 '22 at 01:50
  • I think you have a mistake in your `RewriteRule`. I think it should look like this: `RewriteRule ^post/([A-Za-z0-9-]+?)/?$ /post.php?name=$1 [NC, L]` – matronator Sep 13 '22 at 11:50

1 Answers1

0

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]
matronator
  • 465
  • 6
  • 13