.htaccess Not Working Properly In IE

偶尔善良 提交于 2020-01-06 19:41:47

问题


My .htaccess file is not working in IE, It works fine in FireFox and Chrome, but in IE images wont load, and links don't work correctly ether. The CSS works fine and all the PHP seams to be working aswell.

I am pretty sure that it has something to do with me needing to pull 2 GET variables from the url, because it works fine when I only need to pull one variable. Anyway here is my code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)/([^/]+)/?$ /website/index.php?id=$1&c=$2

Please help, I have been looking for hours for a solution for this.


回答1:


I don't see how ANY rewrite conditions would be browser dependent.. your problem must be somewhere else.

maybe try removing the leading / from your rule:

RewriteRule ^([^/]+)/([^/]+)/?$ /website/index.php?id=$1&c=$2



回答2:


Everything is working except for images and links, for example, lets say the base url is localhost/website/148/category and I click a link that should take me to localhost/website/149/category it takes me to localhost/website/148/category/149/category. So it is just adding onto the url it seams.

This is a relative/absolute URI issue, and not anything to do with your rewrite rules. Using the <base> tag is supposed to fix this but there's bugs in versions of IE8 which causes it to be ignored without a FQDN in front, something like:

<base href="http://localhost/website/">

(Not even really sure if that fixes the issue).

And yes, it needs to be before all other references and inside the <head> </head> tags. The only other recourse to fixing this is changing all your links to absolute URI's instead of relative ones.



来源:https://stackoverflow.com/questions/12443961/htaccess-not-working-properly-in-ie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!