apache - mod_rewrite url 中带有空格

标签 apache url mod-rewrite

我需要设置一些 RewriteRules 来重定向包含空格的 URL。我试过这个:

RewriteRule ^article/with%20spaces.html$ /article/without_spaces.html [R=301,L]

...但它不起作用。输入空格而不是 %20 会导致 500 内部服务器错误。如何添加空格?

最佳答案

尝试在空格前面加上\来转义它。

RewriteRule ^article/with\ spaces.html$ /article/without_spaces.html [R=301,L]

关于apache - mod_rewrite url 中带有空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/410811/

相关文章:

java - 尝试从 Java 的输出中获取 URL

c++ - 如何在 Windows 中从 C++ 程序打开 url?

wordpress - 自定义帖子类型的自定义永久链接

php - .htaccess 使用 get 参数重写 url

Apache 错误与 throws 类不兼容

asp.net - 从公共(public)访问中保护 MediaWiki 在 Linux PHP 上验证 Windows ASP 服务器

apache - 使用 rewrite -phpmyadmin 在 URL 中的任何位置捕获不良行为

apache - 如何使用 Apache 运行多个启用 SSL 的网站以进行本地开发

c - 如何用C语言打开网址?

php - htaccess 重写 url,如 Stack Overflow