Apache Simple.htaccess重写规则,但不';我不能正常工作

Apache Simple.htaccess重写规则,但不';我不能正常工作,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我试图重写一个url,但有些东西不能正常工作,我得到了消息 找不到 在此服务器上找不到请求的URL/1/1.html 这是我在.htaccess中的内容 Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^/([^/]*)/([^/]*)\.html$ /view.php?id=$1&nam

我试图重写一个url,但有些东西不能正常工作,我得到了消息

找不到 在此服务器上找不到请求的URL/1/1.html

这是我在.htaccess中的内容

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^/([^/]*)/([^/]*)\.html$ /view.php?id=$1&name=$2 [L]
这是本案例的
href
链接

href="/'.$row['id'].'/'.$row['name'].'.html"

知道为什么吗?

您必须删除规则中的前导斜杠

RewriteRule ^([^/]+)/([^/]+)\.html$ /view.php?id=$1&name=$2 [L]
只有直接在
httpd.conf
而不是
.htaccess
文件中编写时,才需要在规则中使用前导斜杠


如果我没有犯错误,你也需要它,直到Apache2.4。谢谢你的回答。css样式现在怎么样了,因为它已经消失了…啊,是的。。我的错误。再次感谢你!这是因为您已使用规则创建了一个虚拟目录。您所要做的就是为所有html资源使用绝对路径。您还可以在所有相关页面的
html标记之后添加