Php .htaccess:用静态url重写动态url
我想输入Php .htaccess:用静态url重写动态url,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我想输入http://localhost:81/admin/dashboard在我的浏览器中,但请求应为http://localhost:81/admin/index.php?page=dashboard mod_重写已启用,我在.htaccess中尝试了此操作,但没有成功。.htaccess位于htdocs/admin/.htaccess中: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_F
http://localhost:81/admin/dashboard
在我的浏览器中,但请求应为http://localhost:81/admin/index.php?page=dashboard
mod_重写已启用,我在.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]
您可以选择在模式中的尾随斜杠旁边添加一个?,以匹配尾随斜杠:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=$1 [NC]
RewriteRule
中的正则表达式以斜杠结尾,但您使用的url路径是http://localhost:81/admin/dashboard
没有。正则表达式将与该url不匹配。谢谢,我添加了相同的RewriteRule,但没有斜杠,现在可以使用:)您在RewriteRule
中的正则表达式以斜杠结尾,但您使用的url路径是http://localhost:81/admin/dashboard
没有。正则表达式将与该url不匹配。谢谢,我添加了相同的重写规则,但没有斜杠,现在可以使用了:)