htaccess从URL中删除2个子链接

时间:2017-01-12 16:31:47

标签: apache .htaccess redirect url-rewriting

示例:

重定向

http://domain.com/portfolio/items/wearable-hydration-monitor 

http://domain.com/wearable-hydration-monitor

2个子文件夹将始终相同,/ portfolio / items /

该变量将是wearable-hydration-monitor

我不确定为什么这不起作用:

RewriteEngine On
RewriteRule ^/portfolio/items/(.*)$ http://domain.com/$1 [L,R=301]

1 个答案:

答案 0 :(得分:1)

弄明白:)

RedirectMatch 301 /portfolio/items/(.*)$ http://domain.com/$1