当我尝试使用图像标签显示图像时,显示图像存在问题。现在图像是项目/图像/徽标。我正在显示图像的页面位于project / projectadmin / file.php中。
图像路径如下http://localhost/project/images/logo/cat_149.jpg所示。当我删除htaccess,然后显示图像没有问题。此外,当我使用像http://localhost/project/projectadmin/images/logo/cat_149.jpg移动图像的图像路径到项目/ projectadmin / images / logo /时,显示图像没有问题。
我的问题是什么?
RewriteEngine On
ReWriteBase /project
RewriteRule ^(cat|Home|index.htm|)$ index.php [L,NC]
RewriteRule ^signin/(.*)$ Login.php?a=$1 [L,NC]
RewriteRule ^create_account/(.*)/(.*)$ createacc.php?v1=$1&v2=$2 [L,NC]
RewriteRule ^signup/(.*)$ createacc.php?var1=$1&var2=$1&var3=signup [L,NC]
RewriteRule ^myhope/(.*)$ home.php?var11=$1 [L,NC]
RewriteRule ^edit_account/(.*)$ edit_account.php?var12=$1 [L,NC]
RewriteRule ^edit_account_ship_pr edit_account_ship.php [L,NC]
RewriteRule ^edit_account_b/(.*)$ editacc.php?action=$1 [L,NC]
答案 0 :(得分:0)
你很可能.htaccess文件使用类似mod_rewrite的东西来重写_urls。然后,当您去抓取图像时,它会将该URL重写为类似PHP文件的内容。
亲自前往IMG地址,看看会发生什么。您可能也看不到图像。
对此最简单的解决方法可能是检查文件是否存在。如果是这样,请不要重定向。这样做:
RewriteCond %{SCRIPT_FILENAME} -f
RewriteCond %{SCRIPT_FILENAME} -d
因此,您的HTACCESS文件看起来像
RewriteEngine On
ReWriteBase /project
RewriteCond %{SCRIPT_FILENAME} -f
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^(cat|Home|index.htm|)$ index.php [L,NC]
RewriteRule ^signin/(.*)$ Login.php?a=$1 [L,NC]
RewriteRule ^create_account/(.*)/(.*)$ createacc.php?v1=$1&v2=$2 [L,NC]
RewriteRule ^signup/(.*)$ createacc.php?var1=$1&var2=$1&var3=signup [L,NC]
RewriteRule ^myhope/(.*)$ home.php?var11=$1 [L,NC]
RewriteRule ^edit_account/(.*)$ edit_account.php?var12=$1 [L,NC]
RewriteRule ^edit_account_ship_pr edit_account_ship.php [L,NC]
RewriteRule ^edit_account_b/(.*)$ editacc.php?action=$1 [L,NC]
请注意,将允许直接访问任何.php文件,但这应该无关紧要,考虑到你没有任何障碍可以阻止它。