.htaccess的URL中的空格

时间:2014-06-06 13:34:07

标签: .htaccess url redirect joomla rewrite

我尝试了多次不同的重写,但没有一次重写。

这不起作用:

RewriteRule ^/images/stories/emailsig/DiVal_Hand_Protection_Catalog_2014\sLR.pdf http://www.divalsafety.com/images/Catalogs/DiVal_Hand_Protection_Catalog_2014_LR.pdf

这也不起作用:

Redirect /images/stories/emailsig/DiVal_Hand_Protection_Catalog_2014 LR.pdf http://www.divalsafety.com/images/Catalogs/DiVal_Hand_Protection_Catalog_2014_LR.pdf [NE]

试图找出我在这里做错了什么。根据与此主题相关的所有帖子,我认为我可以解决它,但它不适合我。

更新3:

 #  mod_rewrite in use
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
    RewriteRule ^images/stories/emailsig/DiVal_Hand_Protection_Catalog_2014\ LR\.pdf$ http://www.divalsafety.com/images/Catalogs/DiVal_Hand_Protection_Catalog_2014_LR.pdf [L,NC,NE,R=302]
    ########## Begin - Rewrite rules to block out some common exploits
    ## If you experience problems on your site block out the operations listed below
    ## This attempts to block the most common type of exploit `attempts` to Joomla!
    #
    # Block out any script trying to set a mosConfig value through the URL
    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
    # Block out any script trying to base64_encode crap to send via URL
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
    # Block out any script that includes a <script> tag in URL
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    # Block out any script trying to set a PHP GLOBALS variable via URL
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    # Block out any script trying to modify a _REQUEST variable via URL
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    # Send all blocked request to homepage with 403 Forbidden error!
    RewriteRule ^(.*)$ index.php [F,L]
    #
    #
    ########## End - Rewrite rules to block out some common exploits

1 个答案:

答案 0 :(得分:1)

几乎没有问题:

  1. 您正在将mod_rewrite语法与mod_alias
  2. 混合使用
  3. RewriteRule in。htaccess`
  4. 中的URI中没有匹配前导斜杠
  5. 空间需要转义或引用
  6. 此规则应该在您的根目录中工作.htaccess:

    RewriteEngine On
    
    RewriteRule ^images/stories/emailsig/DiVal_Hand_Protection_Catalog_2014\ LR\.pdf$ http://www.divalsafety.com/images/Catalogs/DiVal_Hand_Protection_Catalog_2014_LR.pdf [L,NC,NE,R=302]