CSS path after IIS url rewrite |
[eluser]vertmonkee[/eluser]
I followed the instructions on this page http://codeigniter.com/wiki/Miscellaneous/ and everything works fine for removing index.php from urls. This has now caused my CSS file to not be found. The file is in a folder structure like this from the root assets/css/stylesheet.css I've tried the following http://mysite.com/assets/css/stylesheet.css /assets/css/stylesheet.css assets/css/stylesheet.css But none of those options work. My web config file looks like this Code: <?xml version="1.0" encoding="UTF-8"?> Can anyone suggest how to fix this? Thanks for any help
[eluser]danmontgomery[/eluser]
Try adding the assets directory to the rule that doesn't get rewritten: Code: <match url="(index.php|robots.txt|images|test.php|assets)" />
[eluser]vertmonkee[/eluser]
[quote author="noctrum" date="1271371185"]Try adding the assets directory to the rule that doesn't get rewritten: Code: <match url="(index.php|robots.txt|images|test.php|assets)" /> Thanks for your quick reply. I added assets to the rule but it's still not working, even though when I test the pattern in IIS it says it is ok. Any other ideas? Thanks
[eluser]danmontgomery[/eluser]
When you go to http://mysite.com/assets/css/stylesheet.css in your browser, does it load? Do you get an IIS 404? CI 404?
[eluser]danmontgomery[/eluser]
Interesting... I'm not familiar enough with IIS to be any more help, I don't think
[eluser]vertmonkee[/eluser]
No problems, thanks for your help so far. When I read your first post I was convinced that would work perfect first time. Thanks again
[eluser]danmontgomery[/eluser]
Might the problem be that you don't have an action for the first rule? Something like: Code: <rule name="codeigniterRuleOne"> (again, not real familiar with IIS, syntax may be wrong)
[eluser]vertmonkee[/eluser]
Thanks for coming up with another good suggestion, unfortunately that one produces a 500 error. I created the rules in the IIS GUI so I expect the actual rules to have been written to the config file correctly.
[eluser]vertmonkee[/eluser]
Right, I've got it sorted. The rules were in the correct order I needed to tell it to stop processing rules after it matched the first one. I did this in the IIS GUI, it's just a checkbox. And this is the resultant config file <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="codeigniterRuleOne" stopProcessing="true"> <match url="index.php|robots.txt|images|test.php|assets" /> <conditions logicalGrouping="MatchAll" /> </rule> <rule name="codeigniterRuleTwo"> <match url=".*" /> <conditions logicalGrouping="MatchAll" /> <action type="Rewrite" url="index.php/{r:0}" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration> Thanks to noctrum for his very good suggestions which helped me whittle down the options to find the solution. |
Welcome Guest, Not a member yet? Register Sign In |