Search code examples
.htaccessurlmasking

URL Masking with htaccess 1


so this is my url:

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

I want to write the following htaccess:

if PropertyBuyRent=rent and Resort value is not empty then url should be like:

http://www.mysite.com/mypage.php/TimeshareForRent/Marriott's+Grande+Ocean+Resort (whatever value comes from the url for Resort)


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/%2? [R=301,L,NE]
    
    RewriteRule ^(testing/mypage.php)/TimeshareForRent/([^/]+)/?$ /$1?PropertyBuyRent=rent&Developer=&Resort=$2&City=&State=&Country=&Price= [L,NC,QSA]