Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess:用静态url重写动态url_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

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不匹配。谢谢,我添加了相同的重写规则,但没有斜杠,现在可以使用了:)