dongyan5641 2016-09-01 09:50
浏览 122

301在.htaccess文件中从双斜杠重定向到一个斜杠

I want to redirect some urls with 301 status code

Example:

from www.domain.com//brands/ to www.domain.com/brands/

from www.domain.com//brands/brand1 to www.domain.com/brands/brand1

I've tried this

Redirect 301 //brands/ /brands/

It mostly works. But on this url doesn’t www.domain.com/brands/brand1 gets redirected to www.domain.com/brandsbrand1

  • 写回答

2条回答 默认 最新

  • dscrn1974 2016-09-01 09:57
    关注

    try this rule,

    RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
    RewriteRule / http://www.example.com/%1/%2 [R=301,L]
    

    also you can try with RedirectMatch:

    RedirectMatch 301 ^(.*)//+(.*)$ http://www.example.com/$1/$2
    
    评论

报告相同问题?