Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

.htaccess query string redirect with same value

I want to redirect URLs with a query string to another query string using .htaccess

From: https://example.com/?smp=123456 (Any number after =)

To: https://example.com/?p=123456 (Same number as in From URL)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried following but it’s not working.

RewriteEngine on
RewriteCond %{QUERY_STRING} ^/?smp=([0-9]+)$ [NC]
RewriteRule ^$ https://www.example.com/?p=$ [R=301,L]

>Solution :

RewriteEngine On
RewriteCond %{QUERY_STRING} ^smp=([0-9]+)$ [NC]
RewriteRule ^$ /?p=%1 [R=301,L]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading