Hi! First of all I am very new to Stack Overflow so excuse me if I did something wrong.
I need some help on the .htaccess to rewrite a rule for a SEO friendly URL. Basically it is a blog and I get blog post data not with an $id but with a sef URL parameter. I know that search engines does not like URL parameters because it is hard to identify what is what.
"sef" parameter dynamically changes according to the blog post content I show. I want to get the part after "=" and delete parameter name(?sef) and put a "/" in between which looks like this.
Current URL structure (with a "sef" parameter)
https://www.dent.com.tr/gelismeler.php?sef=dis-tedavisi-nasil-genclestirir
I want to rewrite this url as
https://www.dent.com.tr/gelismeler/dis-tedavisi-nasil-genclestirir
I check/set page content data dynamically from a mysql database within gelismeler.php
if (isset($_GET['sef'])) {
$sef = $_GET['sef'];
$sql = "SELECT * FROM posts WHERE sef='$sef'";
$query = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($query);
$title = $row["title"];
$desc = $row["description"];
$img = $row["image"];
I've tried countless variations but actually I've never succeed :(
Can anybody help me with this?
Thanks a lot!
My current.htacces file:
ErrorDocument 404 /404.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php
RewriteCond %{HTTP_HOST} !^www.dent.com.tr$
RewriteRule ^(.*)$ http://www.dent.com.tr/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC]
RewriteRule ^index\.php$ http://www.dent.com.tr/ [R=301,L]