Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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
Html 重写规则-链接问题_Html_Mod Rewrite_Url Rewriting - Fatal编程技术网

Html 重写规则-链接问题

Html 重写规则-链接问题,html,mod-rewrite,url-rewriting,Html,Mod Rewrite,Url Rewriting,我有一条规则: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [NC] RewriteRule ^user/(.*)$ user.php?user=$1 [NC,L] 这提供了一个很好的Url: localhost/user/myname 而不是: localhost/user.

我有一条规则:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC]
RewriteRule    ^user/(.*)$    user.php?user=$1    [NC,L]    
这提供了一个很好的Url:

localhost/user/myname
而不是:

localhost/user.php?user=myname
一切都很好,除了当我点击这个页面标题中的徽标

<div class="logo">
    <a href="index.php"><h2>Mylogo</h2></a>
</div> 

斜杠将带您返回根文件夹

<div class="logo">
    <a href="/"><h2>Mylogo</h2></a>
</div> 


我可能误解了,但是user.php与链接的页面如何相同?当我单击链接时,它会重新加载user.php而不是index.php,您希望链接将您带到哪里?
<div class="logo">
    <a href="/"><h2>Mylogo</h2></a>
</div>