How do I redirect from example.com/file.php
to example.com/file.php?id=1
with .htaccess
?
I want that .htaccess
adds automatically the ?id=1
to this specific link, but not to other .php
files, only this specific file.php
.
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)id=1(&|$) [NC]
RewriteRule ^file\.php$ $0?id=1 [L,NC,QSA,R=302]