.htaccess:用静态网址重写动态网址

时间:2016-03-23 22:36:02

标签: php apache .htaccess mod-rewrite

我想在浏览器中输入http://localhost:81/admin/dashboard,但请求应为http://localhost:81/admin/index.php?page=dashboard

mod_rewrite已启用,我在.htaccess中尝试了这个但它没有用。 .htaccess位于htdocs / admin / .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.php?page=$1  [NC]

1 个答案:

答案 0 :(得分:0)

您可以通过在模式旁边添加来匹配尾部斜杠:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1  [NC]
相关问题