I want to rewrite the below:
- http://www.mywebsite/address/12345/ to http://www.mywebsite/address/?param1=12345
- http://www.mywebsite/address/12345/12 to http://www.mywebsite/address/?param1=12345¶m2=12
- http://www.mywebsite/address/12345/?{otherparam}=1 to http://www.mywebsite/address/?param1=12345&{otherparam}=1
Below is what I have in the .htaccess file. I have the first two working fine yet am struggling with the 3rd. I need the third to pass param1 & moreover pass other optional parameters. Can anyone assist?
RewriteRule ^address/([^/.]+)/?$ address/?param1=$1 [NC]RewriteRule ^address/([^/]+)/([^/.]+)/?$ address/?param1=$1¶m2=$2 [NC]
You’re looking for the QSA
flag, which appends any existing query string to the newly constructed one in the rule’s target:
RewriteRule ^address/([^/.]+)/?$ address/?param1=$1 [NC,QSA,L]RewriteRule ^address/([^/]+)/([^/.]+)/?$ address/?param1=$1¶m2=$2 [NC,QSA,L]
No comments:
Post a Comment