Wordpress .htaccess重写不会生效

时间:2016-02-25 19:32:11

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

我在wordpress中有这些规则.htaccess:

http://test.com/some Folder/some Other subfolder/Some File Name.jpg

我需要触发另一个规则,该规则将仅应用%20替换文件名,但它不会生效:

http://test.com/wordpress/some Folder/some Other subfolder/some-file-name.jpg

我需要测试的URL示例是:

@RequestMapping(value="/myerror", method = RequestMethod.GET))
public ResponseEntity myerror(){
    return new ResponseEntity(HttpStatus.BAD_REQUEST);
}

需要的结果:

{{1}}

我做错了什么?我怎么能用它完成?

1 个答案:

答案 0 :(得分:1)

DocumentRoot/.htaccess中尝试使用此规则替换带连字符的空格:

RewriteRule ^(?:wordpress/)?(.*/)?([^\s\x20/]*)[\s\x20]+([^/]*)$ /wordpress/$1$2-$3 [R=302,L,NE]