全局301文件夹重定向,其中包含url中的条件和空格(%20)

时间:2015-10-22 07:26:13

标签: apache .htaccess mod-rewrite redirect url-rewriting

我有一个旧的文件夹结构如下

http://www.example.com/2014_Files/.../...
http://www.example.com/2012 files/.../...
http://www.example.com/2013 Files/.../...
http://www.example.com/All 2009 Files/.../...

该列表包含16个文件夹, RewriteCond 会执行此操作,但是我将以下重定向作为上述一般规则的例外:

Redirect 301 "/2013 Files/Gallery D Dest/index.htm"             http://www.example.com/different_location
Redirect 301 "/2014_Files/Fest_4_Dest_/index.htm"               http://www.example.com/different_location
Redirect 301 "/2014_Files/AssrtDEST/index.htm"                  http://www.example.com/different_location
Redirect 301 "/2013 Files/Gallery B Dest/"                      http://www.example.com/different_location
Redirect 301 "/2014_Files/RPen_A _dest/index.htm"               http://www.example.com/different_location
Redirect 301 "/2014_Files/NewFest_Sub/index.htm"                http://www.example.com/different_location
Redirect 301 "/2013 Files/Gallery E/Gallery E dest/index.htm"   http://www.example.com/different_location
Redirect 301 "/2014_Files/Dest_B_dest/index.htm"                http://www.example.com/different_location
Redirect 301 "/2013 Files/Bob_Gallery_2_Dest/index.htm"         http://www.example.com/different_location
Redirect 301 "/2013 Files/Gallery FDest/index_2.htm"            http://www.example.com/different_location

我无法构建一个有效的规则集,一个问题是旧网址结构中的空格,我能够使用引号部分修复,但我无法有效地包含异常,获得500个错误。任何帮助是极大的赞赏! 谢谢!

1 个答案:

答案 0 :(得分:2)

诀窍是使用" \ s"使用" \"而不是重定向规则左侧的空格。在右边。因此规则应如下所示:

def get_names_start(self,first_char,tools = None)