[英].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.