mod_rewrite 在 url 中有空格 [英] mod_rewrite with spaces in the urls

查看:26
本文介绍了mod_rewrite 在 url 中有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to set up some RewriteRules to redirect a URL which has a space in it. I've tried this:

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

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

... but it doesn't work. Putting in a space instead of %20 causes a 500 Internal Server Error. How do I add a space?

推荐答案

尝试在您的空间前面放一个 \ 以避开它.

Try putting a \ in front of your space to escape it.

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

这篇关于mod_rewrite 在 url 中有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆