Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ISAPI_Rewrite - Coldfusion 9.0.1 and IIS 7.5

Explorer ,
Apr 04, 2012 Apr 04, 2012

I need to resolve canonical URLs :

non-www version should be redirected (301) to www (all pages)

IP address should be redirected to www.mywebsite.com

www.mywebsite.com/index.cfm should be redirected to www.mywebsite.com

I would really appreciate your help on this one as the following code (.htaccess file) redirects only non-www version to www

I'm not sure what to change/add to include all of the above rules.

RewriteEngine on

RewriteCond %{HTTPS} (on)?

RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]

RewriteCond %{REQUEST_URI} (.+)

RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 04, 2012 Apr 04, 2012

Well this has nothing to do with ColdFusion or IIS, but okay.

Don't bother using ISAPI_Rewrite. IIS7 has its own built-in rewrite engine with a GUI, use that instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2012 Apr 04, 2012

Technically its not built in but you can grab it from here: http://www.iis.net/download/URLRewrite

They have a rule template for exactly what you want to do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 04, 2012 Apr 04, 2012

not sure that I can use it due to shared hosting !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2012 Apr 04, 2012

Well, yeah.  That will cramp your style.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 05, 2012 Apr 05, 2012

I've just received a reply from my hosting provider, "we recommend using the isapi_rewrite but you can use iis URL Rewrite Module

by setting up a web.config file" !  so,can you guys give me some pointers? really do not know where to start. how can I include all the rules mentioned above?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 05, 2012 Apr 05, 2012

Why would they recommend using isapi (an old technology) over URL Rewrite, which is a new technology? There's a GUI you can use through IIS, although I appreciate you can't use that on shared hosting. However, all the GUI does is creates an XML file (web.config) in your web root with the rules in.

Use the GUI on your dev server and copy up the web.config with the rest of your files, job done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 05, 2012 Apr 05, 2012

thanks for the advice Owain, I've already done that. here is the code :

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

    <system.webServer>

        <rewrite>

            <rules>

                <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">

                    <match url="*" />

                    <conditions>

                        <add input="{HTTP_HOST}" pattern="domain.com" />

                    </conditions>

                    <action type="Redirect" url="http://www.domain.com/{R:0}" />

                </rule>

                <rule name="redirect index.cfm to www.domain.com" patternSyntax="Wildcard" stopProcessing="true">

                    <match url="index.cfm" />

                    <conditions>

                    </conditions>

                    <action type="Redirect" url="http://www.domain.com/" />

                </rule>

                <rule name="rediret IP address to www.domain.com" patternSyntax="Wildcard" stopProcessing="true">

                    <match url="*" />

                    <conditions>

                        <add input="{HTTP_HOST}" pattern="11.222.333.444" />

                    </conditions>

                    <action type="Redirect" url="http://www.domain.com/{R:0}" />

                </rule>

            </rules>

        </rewrite>

    </system.webServer>

</configuration>

is everything ok with the code above? is there anything I should change to

1. redirect non-www version to www

2. redirect IP address to http://www.domain.com/

3. redirect index.cfm to http://www.domain.com/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 05, 2012 Apr 05, 2012

Honestly I have no idea, as I said this is a ColdFusion forum not an IIS one so I can't help I'm afraid. Does it do what you expect it to?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 06, 2012 Apr 06, 2012
LATEST

I spent several hours reading/learning more about IIS URL Rewrite Module and I can safely say that I'm simply amazed at how well it works! So, who on earth would use ISAPI_Rewrite ever again as both simple and more sophisticated rules can be added easily with URL Rewrite 2.0 (for advanced rules you need to be familiar with regular expressions ofcourse). Anyway, I will continue to read about this new technology and hopefully will be able to help someone if needed in the future

"Does it do what you expect it to?" , yup, it works like a charm

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources