例如:
www.site.com/your/blue
www.site.com/your/blue
将重定向到... www.site.com/your/index.php?=blue
will redirect to... www.site.com/your/index.php?=blue
当有人类型www.site.com/your/blue它抛出一个错误说的页面不存在现在。 谁能帮助我呢?预先感谢您。
right now when someone types in www.site.com/your/blue it throws an error saying page does not exist. can anyone help me with this? thank you in advance.
mod-rewrite已用于这种重定向:
Mod rewrite has to be used for this kind of redirects:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ $1/index.php?page=$2 [L]
</IfModule>
这正则表达式保证一个干净的URL被传递到网站和作品有或没有结束斜线。
This regex ensures a clean url is being passed to the site and works with or without a ending slash.
注:传递给PHP参数需要有一个名称,所以我加页=
NB: Parameters passed to PHP need to have a name so I added page=
如果你想让它不受任何限制上班(空格将工作)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/?$ $1/index.php?page=$2 [L]
</IfModule>