fish man
fish man

Reputation: 2720

.htaccess URL redirection

This may be a simple question. But I am not good at .htaccess redirection rules, so I opened a question.

I want redirection like this:

If url like: www.mydomain.com/image/12345, www.mydomain.com/image/12346.

do a redirection like: www.mydomain.com/products/image/12345, www.mydomain.com/products/image/12346. (add /products/ for the page if url end like image/number and no /products/ for itself.)

I have already do some redirection rule like:

RewriteRule ^(products/image)/(\d+)/?$ products/image?photo=$2

in .htaccss. Thanks.

Upvotes: 1

Views: 120

Answers (1)

Jon Lin
Jon Lin

Reputation: 143966

Try this instead:

RewriteRule ^images/([0-9]+)/?$ /products/image/$1 [L,R=301]

to redirect www.mydomain.com/image/12345 to www.mydomain.com/products/image/12345. Then you're other rule should take affect and internally rewrite it.

Upvotes: 1

Related Questions