Reputation: 151
I want to make my URL from this:
https://www.website.com/index.php?title=A1-13-05-2021
to this:
https://www.website.com/A1-13-05-2021
And want to access above query string param in index.php as $_GET['title'].
For this, I have written the below .htaccess code. But that's not working
RewriteEngine On
RewriteRule ^index?$ index.php
RewriteRule ^index/([a-zA-Z0-9\-]+) index.php?title=$1
Can anyone please help me to know where I am doing wrong?
Thanks.
Upvotes: 3
Views: 648
Reputation: 133750
With your shown samples, could you please try following. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##Rule for handling non-existing pages here to index.php file.
RewriteRule ^(A1-13-05-2021)/?$ index.php?title=$1 [QSA,NC,L]
Generic Rules: In case you want to make it Generic rules then try following rules only.
RewriteEngine ON
##Rule for handling non-existing pages here to index.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(A1-\d{2}-\d{2}-\d{4})/?$ index.php?title=$1 [QSA,NC,L]
Upvotes: 3