The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: IIS 7 & URL Rewrite
PostPosted: Fri Jan 23, 2009 11:09 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Aug 18, 2008 2:37 pm
Posts: 7
I've searched the forums and although there are a few URL rewrite questions I felt it would be better to ask my own as it's a little more detailed and specific.

I recently upgraded my server to Windows Server 2008 & IIS 7 with Microsoft's URL Rewrite Module. As a test, I imported the Joomla htaccess file into a new URL Rewrite rule and everything imported just fine with the exception of the following line:
Code:
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
I immediately proceeded to my browser to test the rewriting rules only to find that I got a 404 error. Some checking showed me that my rules weren't matching correctly, though it was nothing to do with the fact that the line above was missing. After a quick browse to iis.net's 7 URL Rewrite Module forum I discovered there was an issue parsing {SCRIPT_NAME} and that, as a workaround, it should be replaced with {URL}

After doing this, I found that the rewrite rules were now working, but all apache style SEF urls would take me to my index page and not show the actual page. More clearly:

/index.php/about - takes me to my about page
/about, /services, /contact, etc - shows the homepage

Does anyone know why this could be happening? Also, what is the E=HTTP_AUTHORIZATION line supposed to do and could it be affecting the script?

For anyone's reference, the final URL Rewrite Module code is here:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Execute, Script" />
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" />
                        <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" />
                        <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" />
                        <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                        <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
                    </conditions>
                    <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                </rule>
                <rule name="Imported Rule 2">
                    <match url="(.*)" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" />
                        <add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


Some brainstorming on this would be great, I'd really like to get it working, as I'm sure others would too.

Andy


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Fri Jan 30, 2009 9:10 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Jan 30, 2009 9:07 pm
Posts: 2
Check this article: http://learn.iis.net/page.aspx/527/joomla-on-iis/. Specifically, make sure that in the "SEO Settings" on "Global configuration" page you set "Use Apache mod_rewrite" to "Yes".


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Tue Feb 24, 2009 3:28 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jan 26, 2009 3:44 am
Posts: 15
ruslany wrote:
Check this article: http://learn.iis.net/page.aspx/527/joomla-on-iis/. Specifically, make sure that in the "SEO Settings" on "Global configuration" page you set "Use Apache mod_rewrite" to "Yes".


Did that actually work for you? I can confirm rokujou 's two issues: either get 404's (if importing rules through the URL Rewrite module) or the content from the home page is always shown when navigating to other URL's.

I had started another thread at viewtopic.php?f=544&t=374703 before finding this thread, but I guess we should continue the discussion here.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Tue Feb 24, 2009 6:23 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Jan 30, 2009 9:07 pm
Posts: 2
Yes, that worked for me. I've seen similar issues reported before and in those cases it turned out that the reason was that IIS7 was configured to run PHP either via ISAPI or via CGI. IIS7 needs to be configured to use FastCGI to run PHP. Is that how your IIS is configured?


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Tue Feb 24, 2009 9:10 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jan 26, 2009 3:44 am
Posts: 15
ruslany wrote:
Yes, that worked for me. I've seen similar issues reported before and in those cases it turned out that the reason was that IIS7 was configured to run PHP either via ISAPI or via CGI. IIS7 needs to be configured to use FastCGI to run PHP. Is that how your IIS is configured?


Ah, you're right. It works now. I had tried the FastCGI before but I was getting weird results -- I was only getting the html text, with no color or styling. I've duplicated this again this time by turning off "Use Apache mod_rewrite" and having the rewrite rules in place. However, if I turn on "Use Apache mod_rewrite", then it all works fine: I get proper styling, I get the right URL's (without "index.php" in the address bar), and the right content is loaded. Fantastic!


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Sat Feb 28, 2009 5:20 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Feb 28, 2009 5:02 pm
Posts: 2
ok


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Sat Sep 12, 2009 11:50 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Sep 12, 2009 11:48 pm
Posts: 1
I have a similar issue. I'm using exactly the same settings but for some reason, my root won't load... I get a 404. All other files load fine (articles, etc)... it's just when I go to the my root domain.

For example http://www.Junk-Domains.com gives me a 404 error.

http://www.Junk-Domains.com/cool-jazz works beautifully.

Any ideas?

IIS 7/Joomla 1.5.14/latest PHP and FastCGI


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Sat Oct 24, 2009 9:41 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Oct 23, 2009 9:39 am
Posts: 10
Hi Seeed,

Your website does not have any default document defined when you type http://www.Junk-Domains.com

Please add the follow code below <system.webserver> in your web.config file:

<defaultDocument>
<files>
<clear />
<add value="index.php" />
<add value="Default.asp" />
<add value="Default.htm" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>

Hope this will work.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Mon Dec 06, 2010 8:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 12, 2010 2:25 pm
Posts: 14
How can I set PHP to run with FastCGI and not ISAPI ?


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Thu Apr 28, 2011 1:45 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Apr 10, 2011 10:39 pm
Posts: 19
I've been struggling with this for two days now. The code you have fixed it.

Randy


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Tue May 03, 2011 1:36 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue May 03, 2011 1:32 pm
Posts: 2
Location: California
Upgrading to IIS 7 should be rather transparent, unfortunately that is not the case when it comes to URL rewriting as we knew it from IIS 6.

Thanks!

_________________
Please read forum rules regarding the use of signatures: viewtopic.php?f=8&t=65


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Tue May 03, 2011 10:36 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Joomla 1.6.3 (onwards) now includes some sample code for URL rewriting with IIS.

_________________
Online since 1995.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Wed Sep 14, 2011 6:48 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Sep 13, 2011 7:07 am
Posts: 6
I've been struggling with this for two days now. The code you have fixed it. :D


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Mon Nov 21, 2011 5:24 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Nov 19, 2011 7:29 pm
Posts: 2
@ ruslany I am having the same problem but I clicked on the link you gave unfortunately it is either down or outrightly no longer working. Can you please check the link?

P:S : Is there a place on this forum I can find people who can fully customize a Joomla blog for me? I need to sell the blog but it looks Ugly.


Last edited by ooffick on Thu Mar 15, 2012 10:29 pm, edited 1 time in total.
Mod Note: Removed manual Signature. Please read the Forum rules for details.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Sat Oct 20, 2012 7:22 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
You've posted in the IIS7 thread, rather than an Apache thread.

_________________
Online since 1995.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Wed Nov 07, 2012 12:22 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
As soon as I see this
Code:
(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$

I know it is a very old version of the code.

Get a newer copy of the IIS code from a more recent Joomla installer; do this even if you are continuing to use an old version of Joomla.



Quote:
I guess I find it kind of suspicious that there is no redirect rule; meaning if I copy & paste a 're-written' URL, does't something have to tell the server that is a made-up URL, and it should be redirected to a real URL?

If there was a redirect, the URL shown in your browser address bar would change and the browser would make a new request for the new URL now shown. It would not be using the URL shown in the link you originally clicked on.

No. Instead, the server should be performing an internal rewrite. You ask for example.com/some-page and the server then internally and silently looks for /index.php?page=some-page or some such within the server without revealing the details of that internal path to the outside world.

_________________
Online since 1995.


Top
 Profile  
 
 Post subject: Re: IIS 7 & URL Rewrite
PostPosted: Wed Apr 10, 2013 9:22 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Apr 09, 2013 10:42 am
Posts: 34
That looked promising, but it didn't work. Now I get 404's when I click on links. The url's still look right (as they did initially). The 404 says the physical path looks similar to the (rewritten) URL -- is that expected?

_________________
Joomla!® 2.5 is an award-winning content management system (CMS)
http://www.gogerd.ir.http://www.marl.ir


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group