OmniPotens
OmniPotens

Reputation: 1125

.htaccess Rewrite to this Pattern

I want to rewrite my URLs which is in the format

http://mysite.com/display.php?name=sequin-cuff-swing-dress&id=---DT0001

to

http://mysite.com/sequin-cuff-swing-dress---DT0001

Please can anyone help me with this.

NB: I already have a Rule as below existing for a different URL rewrite.

RewriteRule ^([A-Za-z0-9-]+)?$ /products.php?cat=$1 [L]

Upvotes: 1

Views: 31

Answers (1)

anubhava
anubhava

Reputation: 784898

You can use this rule on top of other rule::

RewriteRule ^([a-z0-9-]+)(---[^/]+)/?$ /display.php?name=$1&id=$2 [L,NC,QSA,NE]

# your existing rule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /products.php?cat=$1 [L,NC,QSA,NE]

Upvotes: 1

Related Questions