junjoi
junjoi

Reputation: 89

Mod url write rules in .htaccess

Need help to create mod url write rules in .htaccess

http://example.com/marketplace/cat/subcat/?city=dubai&area=ajman http://example.com/marketplace/cat/subcat/dubai/ajman where Cat and subcat will change according to category and sub category.

Upvotes: 0

Views: 61

Answers (2)

Amit Verma
Amit Verma

Reputation: 41219

Try this in your .htaccess

RewriteEngine On

RewriteCond %{THE_REQUEST} /marketplace/([^/]+)/([^/]+)/\?city=([^&]+)&area=([^&\s]+) [NC] 
RewriteRule ^ /marketplace/%1/%2/%3/%4? [NE,NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^marketplace/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /marketplace/$1/$2/?city=$3&area=$4 [QSA,L,NC]

Upvotes: 1

Professor Abronsius
Professor Abronsius

Reputation: 33813

This should to do what you want

  RewriteEngine On
  RewriteBase /
  RewriteRule ^marketplace/cat/subcat/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-](/?)$ /marketplace/cat/subcat/?city=$1&area=$2 [NC,L]

Upvotes: 2

Related Questions