htaccess url rewriting without losing url parameters
P粉982881583
P粉982881583 2024-01-10 18:12:30
0
1
527

I created an htaccess URL rewrite to change my URL webseite.com/dashboard.php to webseite.com/dashboard.

My problem is that when I visit certain sites of my website (like https://example.com/detail_user.php?id=1), I provide parameters via the url (using in database data).

According to my rewrite rules, it ignores parameters added to the URL.

Is there any htaccess rule that can provide parameters to a url but remove the .php ending when accessing a normal site?

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/$ .php

P粉982881583
P粉982881583

reply all(1)
P粉724737511

I think what you are looking for is append[QSA].

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/$ .php [QSA]

QSA means "query string append", if a query string was passed in the original URL, it will be appended to the rewrite.

In your use case, /detail_user.php?id=1 becomes /detail_user?id=1

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template