Welcome Guest, Not a member yet? Register   Sign In
CSS path after IIS url rewrite
#1

[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"?>

<configuration>

    <system.webServer>

        <rewrite>

            <rules>

                <rule name="codeigniterRuleOne">

                    <match url="(index.php|robots.txt|images|test.php)" />

                </rule>

                <rule name="codeigniterRuleTwo">

                    <match url=".*" />

                    <action type="Rewrite" url="index.php/{r:0}" appendQueryString="false" />

                </rule>

            </rules>

        </rewrite>

    </system.webServer>

</configuration>

Can anyone suggest how to fix this? Thanks for any help
#2

[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)" />
#3

[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)" />
[/quote]

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
#4

[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?
#5

[eluser]vertmonkee[/eluser]
I get an IIS 404
#6

[eluser]danmontgomery[/eluser]
Interesting... I'm not familiar enough with IIS to be any more help, I don't think
#7

[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
#8

[eluser]danmontgomery[/eluser]
Might the problem be that you don't have an action for the first rule? Something like:

Code:
<rule name="codeigniterRuleOne">
    <match url="(index.php|robots.txt|images|test.php|assets)" />
    <action type="none"/>
</rule>

(again, not real familiar with IIS, syntax may be wrong)
#9

[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.
#10

[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

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

<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.




Theme © iAndrew 2016 - Forum software by © MyBB