帮助mod_rewrite

时间:2011-09-13 08:24:17

标签: php .htaccess mod-rewrite

我有这个.htaac​​ces:

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

RewriteEngine on
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteRule ^([A-Za-z-]+)/?$ index.php?page=$1 [NC,L]

我的页面上有一个链接:

<a href="store/">Store</a>

内容加载,但css文件未正确加载,它在 / store / 目录中加载。我知道我可以使用绝对链接,但我不想。 所以,很快:

www.example.com/store 一切都很有效

www.example.com/store / php查看/ store /文件夹,这是错误的

如何让它以两种方式运作?请帮忙。

1 个答案:

答案 0 :(得分:3)

唯一正确的方法是使用绝对链接 - 否则缓存将无法正常工作,您的页面将加载缓慢。

其他方法是捕获文件“somefile.css”的任何请求并将其重写为您的css - 但这会导致缓存问题

RewriteRule ^.*/(somefile.css)$ cssfloder/$1 [NC,L]
相关问题