Martin
Martin

Reputation: 21

Rewrite only the middle part of URL - mod rewrite .htaccess

I want to change cadeaushop part in the url to hobby-cadeau-shop. I made the following mod rewrite in my htaccess file:

RewriteRule ^cadeaushop/(.*) http://www.zovyo.nl/hobby-cadeau-shop/$1 [QSA,L]

It works nice, but on one place I want something else. the shopping cart uses https, a secure url. Now this url is also set to http.

How can I change the mod rewrite so the first part of the url doesn't change? I tried some changes, like

RewriteRule ^cadeaushop/(.*) /hobby-cadeau-shop/$1 [QSA,L]

But this don't work.

Thanks in advance.

Regards, Martin

Upvotes: 2

Views: 11521

Answers (1)

anubhava
anubhava

Reputation: 784898

You need to use R flag in your rule and avoid using http:// or https:// in target URL.

RewriteEngine On

RewriteRule ^cadeaushop/(.*)$ /hobby-cadeau-shop/$1 [R=302,NE,L]

Also important is to keep this rule just below RewriteEngine On OR RewriteBase line.

Upvotes: 11

Related Questions