.htaccess working“;有时“;而不是';不喜欢相对链接


.htaccess working "sometimes" and doesn't like relative links

我现在正在处理一个项目,几周前的其他项目也使用.htaccess重定向,没有任何问题。我使用的是WAMP的上一个版本,而这次。htaccess让我抓狂。没有重写基。

Apache模块被激活用于重定向,所有模块都应该工作,例如:

RewriteRule ^test$ trying.php [L]

并且trying.php类似于:

<?php
echo "lol";
?>

我有:

ex1http://img11.hostingpics.net/pics/180473es1.png

没错,它应该起作用!然后我尝试访问一个成员页面,但这个成员不存在,所以标题中应该只有页面的标题,my.htaccess就像:

RewriteRule ^member/([A-Za-z0-9]+)$ member.php?id=$1 [L]

并且我获得:

ex2http://img11.hostingpics.net/pics/336923es2.png

因此,除了标题之外,我的页面没有关于用户的信息(正如预期的那样),但它找不到css文件(标题中的相对链接),这不好。

然后我尝试真实的事情,访问这个地址http://localhost/try/member/member1的现有成员,我被重定向到…

ex3http://img11.hostingpics.net/pics/480421es3.png

这是[L]重定向而不是[R],那么为什么会发生这种情况呢?为什么它只发生在现有成员身上?我每次都重新启动WAMP服务,没有任何解释。

您需要有正确的RewriteBase。在你的/try/.htaccess里面有这样的:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /try/
RewriteRule ^test$ trying.php [L]
RewriteRule ^member/([A-Z0-9]+)/?$ member.php?id=$1 [NC,L,QSA]