我将index.php和.htaccess放在localhost/domain/us目录下。在.htaccess中,我有
Options -Indexes
RewriteEngine On
RewriteRule ^/?([a-zA-Z_]+)$ index.php [L]
RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)$ index.php [L] 当我输入url“localhost/ index.php /us/aaa”时,我得到了正确的域名。但是当我输入"localhost/domain/us/aaa/bbb“时,我可以进入index.php页面,但它被搞乱了。所有的css文件似乎都无法工作,图像也出现了。
在index.php中,我使用了
<link rel="stylesheet" href="css/bt.css" type="text/css" media="screen" />
<img src="logo/pic.gif" width="50" alt="logo">logo和css都是localhost/domain/us下的文件夹。为什么目录路径不能正常工作?
发布于 2014-01-02 20:21:03
好了,现在你已经遇到了人们在切换到漂亮的URL方案时面临的最常见的问题:P解决方案也很简单,只需在你的css,js,图像文件中使用绝对路径,而不是相对路径。这意味着您必须确保这些文件的路径以http://或斜杠/开头。
对于您的情况,请使用以下内容:
<link rel="stylesheet" href="/css/bt.css" type="text/css" media="screen" />
<img src="/logo/pic.gif" width="50" alt="logo">https://stackoverflow.com/questions/20882331
复制相似问题