corvidmemory
corvidmemory

Reputation: 23

RewriteRule regex to extract part of a string

I'm having some issues with the following task:

Redirect from:

example.com/catalog/index.php/cPath/24?osCsid=gvil7l7h2vu910f787248i14j4

To:

example.com/mysitenew/index.php?dest=products&cat=24

The trick is to take the number after cPath/ and strip out the ? and everything after it.

I have tried back and forth with regex in RewriteRule but I am not an expert and any suggestions would be appreciated.

Upvotes: 1

Views: 939

Answers (1)

anubhava
anubhava

Reputation: 785146

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^catalog/index\.php/cPath/([^/]+)/?$ /mysitenew/index.php?dest=products&cat=$1 [L,R=302]

Upvotes: 2

Related Questions