Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTACCESS friendly url and allow GET method

My code is

 Options -Multiviews

 RewriteEngine On
 RewriteBase /

 RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L]

If I access

mysite.com/name-of-category.html 

it works, but if I access

mysite.com/name-of-category.html?anything=something

it shows the webpage but $_GET["anything"] shows nothing.

like image 462
ITChristian Avatar asked Dec 29 '25 15:12

ITChristian


1 Answers

You must specify an option called QSA or 'Query String Append':

RewriteRule ^([a-z0-9-]+)\.html$ /index.php?cat=$1 [L,QSA]

It will ensure that the original query strings are also included as part of your new URL.

like image 160
Answerer Avatar answered Jan 01 '26 06:01

Answerer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!