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

冷暖自知 提交于 2020-12-12 08:29:58

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/26801537/rewrite-only-the-middle-part-of-url-mod-rewrite-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!