Trying to build a website (not wordpress), using php... want to override .htaccess file for making Permalinks. I wrote the following, but it doesn't works. I use utf-8 encoding. Hosting on NameCheap hosting. Please help.
RewriteEngine On
RewriteRule ^laptops/$ https://example.com/categories.php?category=$1 [R=301,L]
From the Main file, I am calling categories.php, using the following link:
<a href="/categories.php?category=<? echo strtolower($row1["subcatname"]); ?>" class="card-link" ><? echo $row1["subcatname"]; ?> </a>
Categories.php has the following code:
<?php
if(isset($_GET['category']) && $_GET['category'] == 'laptops') {
echo $_GET['category'] ;
}
?>
.htaccess has the following script:
RewriteEngine On
RewriteRule ^laptops/$ https://onlibest.com/categories.php?category=$1 [R=301,L]
My expectation : https://example.com/categories.php?category=laptops, should be shown to the user as following Permalink https://example.com/laptops