查询重定向并清理

时间:2016-02-02 15:18:55

标签: php

我一直试图让这个工作并观看其他线程,但没有任何对我有用, 我想重定向: http://domain.net/stats.php?player=Matan

于: http://domain.net/stats/Matan

这可能吗?

1 个答案:

答案 0 :(得分:1)

您可以在Apache2上启用 mod_rewrite module时使用.htaccess文件

RewriteEngine on
RewriteRule ^stats/([A-Za-z0-9-]+)/?$ stats.php?player=$1 [NC]

您可以按照这个简单的教程https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite

在这种情况下,我在 RewriteRule 中使用了一个简单的正则表达式,您可以随意自定义正则表达式

编辑:静态文件的例外

RewriteCond %{REQUEST_URI} !(public|css)
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]

,阅读文档

相关问题