Mobile app version of vmapp.org
Login or Join
Sims2060225

: Apache mod_rewrite rule to convert URL of page, keeping parameters same I sent out a link in an email that had a typo in the URL. I need to make a quick change for tracking purposes so

@Sims2060225

Posted in: #Apache #ModRewrite

I sent out a link in an email that had a typo in the URL. I need to make a quick change for tracking purposes so that any incoming hits to the URL are instead parsed to another URL.

From the link sent out:

/app/prog1.php?id=1234


To the version I want to track:

/app/prog2.php?id=1234


How do I set up a RewriteRule to handle such a transformation?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

2 Comments

Sorted by latest first Latest Oldest Best

 

@Fox8124981

don't forget to turn on RewriteEngine
more important: don't forget the QSA at the end of the RewriteRule (QSA = query string append = keep what's after the ?):


Here's what should work:

RewriteEngine On
RewriteRule /app/prog1.php$ /app/prog2.php [QSA,L]


And if you want to track it in your log, do a redirect:

RewriteEngine On
RewriteRule /app/prog1.php$ mywebsite/app/prog2.php [QSA,R,L]


(Not tested but it should work)

10% popularity Vote Up Vote Down


 

@Becky754

This works.

RewriteRule ^app/prog1.php$ /app/prog2.php [L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme