Question

I have a url below:

http://www.mysite.com/mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price=

  1. if PropertyBuyRent=rent and all other variables are empty then url should be like: http://www.mysite.com/mypage.php/TimeshareForRent/All

how can i write htaccess for this?

Was it helpful?

Solution

You can use this rule:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(testing/mypage\.php)\?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [NC]
RewriteRule ^ /%1/TimeshareForRent/All? [R=301,L]

RewriteRule ^(testing/mypage.php)/TimeshareForRent/All/?$ /$1?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]

Reference: Apache mod_rewrite Introduction

OTHER TIPS

You can use this line and make edits in php file as follows

RewriteRule ^mypage.php/TimeshareForRent/All/?$ mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]

You can tell your php file to redirect to "mypage.php/TimeshareForRent/All" when your condition matched, because with above rule, it will mask the url of variables with the one without variable

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top