如何使用.htaccess重写带有空格的url

时间:2015-02-14 10:51:39

标签: .htaccess mod-rewrite url-rewriting

如果'localhost / a / something'是网址,.htaccess会将其重写为'localhost / a / 1.php?food = something'

如果我输入'localhost / a / something something',它会给我404错误。

我现在的.htaccess:

RewriteEngine on
RewriteBase /a/

RewriteRule ^([A-z]+)$ 1.php?food=$1 [L]

我如何'localhost / a / something something'到'localhost / a / 1.php?food = something + something'?

2 个答案:

答案 0 :(得分:1)

请看一下:

How to redirect %20 or White space automatically to + or - with htaccess?

这似乎就是你要做的......

答案 1 :(得分:0)

  

在.htaccess中尝试此规则:

RewriteRule ^article/with\ 1.php$ /food/1.php [R=301,L]