[英].htaccess: Rewrite dynamic url with static url
我想在浏览器中输入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]
您可以通过添加?来匹配尾部斜杠? 在模式旁边:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1 [NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.