如何用 .htaccess 重写 url 和 space
How to rewrite url with space in it with .htaccess
如果 'localhost/a/something' 是 url,.htaccess 将其重写为 'localhost/a/1.php?food=something'
如果我输入 'localhost/a/something something',它会给我一个 404 错误。
我当前的 .htaccess:
RewriteEngine on
RewriteBase /a/
RewriteRule ^([A-z]+)$ 1.php?food= [L]
我怎样才能'localhost/a/something something'到'localhost/a/1.php?food=something+something'?
请看:
How to redirect %20 or White space automatically to + or - with htaccess?
这似乎符合您的要求...
Try this rule in your .htaccess:
RewriteRule ^article/with\ 1.php$ /food/1.php [R=301,L]
如果 'localhost/a/something' 是 url,.htaccess 将其重写为 'localhost/a/1.php?food=something'
如果我输入 'localhost/a/something something',它会给我一个 404 错误。
我当前的 .htaccess:
RewriteEngine on
RewriteBase /a/
RewriteRule ^([A-z]+)$ 1.php?food= [L]
我怎样才能'localhost/a/something something'到'localhost/a/1.php?food=something+something'?
请看:
How to redirect %20 or White space automatically to + or - with htaccess?
这似乎符合您的要求...
Try this rule in your .htaccess:
RewriteRule ^article/with\ 1.php$ /food/1.php [R=301,L]