New url but keep query parameter
5 posts
• Page 1 of 1
New url but keep query parameter
How can I rewrite old urls but keep the querystring parameter?
e.g
old url: myscript.asp?id=1234
new url: mynewscript.asp?id=1234
e.g
old url: myscript.asp?id=1234
new url: mynewscript.asp?id=1234
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: New url but keep query parameter
Hello,
You'll need QSA-flag as in the following:
Regards
Andrew
You'll need QSA-flag as in the following:
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteRule ^myscript\.asp$ /mynewscript.asp [QSA,NC,L]
Regards
Andrew
Re: New url but keep query parameter
Many thanks for the quick response.
I made a mistake in my question.
I need to keep the parameter value but change the querystring parameter name.
e.g.
old url: myscript.asp?id=1234
new url: mynewscript.asp?otherid=1234
I made a mistake in my question.
I need to keep the parameter value but change the querystring parameter name.
e.g.
old url: myscript.asp?id=1234
new url: mynewscript.asp?otherid=1234
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: New url but keep query parameter
In this case:
Regards
Andrew
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^myscript\.asp$ /mynewscript.asp?otherid=%1? [NC,L]
Regards
Andrew
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 21 guests