使用htaccess为页面参数重写url

时间:2017-02-08 11:27:22

标签: .htaccess url-rewriting

始终对重写规则感到困惑。请有人帮帮我。

将参数更改为pagename

这是来自客户端的网址。 http://localhost/project/xxx.html

它应该像这个页面一样在服务器中访问。 http://localhost/project/index.php?param1=xxx

请帮助

1 个答案:

答案 0 :(得分:2)

在项目目录中尝试以下规则我假设项目是您应用规则的目录,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+).html$ index.php?param1=$1 [L]