【问题标题】:RewriteRule - problems with linkRewriteRule - 链接问题
【发布时间】:2018-06-05 15:39:03
【问题描述】:

我有这个 RewriteRule:

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> 

它使用此 URL 重新加载同一页面 (user.php):

http://localhost/user/index.php

【问题讨论】:

  • 我可能理解错了,但是user.php怎么和链接在同一个页面呢?
  • 当我点击链接时它会重新加载 user.php 而不是 index.php

标签: html mod-rewrite url-rewriting


【解决方案1】:

斜线会将您带回根文件夹。

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

【讨论】:

  • 你想把链接带到哪里?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-11
  • 1970-01-01
  • 2013-02-09
  • 1970-01-01
相关资源
最近更新 更多