« Previous Next »

Answered Thread: 301 Redirects with Joomla on IIS7

Last post 09-14-2009 4:18 PM by jtalbot. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 09-08-2009, 6:52 PM

    • jtalbot
    • Not Ranked
    • Joined on 03-03-2009, 8:51 PM
    • Posts 11

    301 Redirects with Joomla on IIS7

    Hello, I just wanted to ask if there are any gotchas with doing 301 redirects for Joomla pages. I had setup some Joomla categories & articles and used a section layout, but I'm not happy with the navigation for various reasons and want to change that.

    At the same time I also want to change the URLs. Right now they show up like this:

    http://www.global-autotrading.com/autotraded-newsletters/18-stock-advisor-group/48-day-trading-stock-picks.html

    I want this to redirect to:

    http://www.global-autotrading.com/autotraded-newsletters/stock-advisor-group/day-trading-stock-picks.html

    Of course, these pages don't actually "exist" at that physical location; I just have all 3 of the SEO options in Joomla turned on, and use URL redirection in the web.config:

         <rewrite>
          <rules>
            <rule name="Security Rule" 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="SEO Rule">
              <match url="(.*)" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
                <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" />
            </rule>
          </rules>
        </rewrite>

    |%3E)" input="{QUERY_STRING}">

    (there's some weird line that shows up in the post: |%3E)" input="{QUERY_STRING}">, but I can't get rid of it, pls just ignore it) 

    I've basically copied the above config, so I don't know too much about the details. How do I combine the above with 301 redirects?

  • 09-08-2009, 9:05 PM In reply to

    • jtalbot
    • Not Ranked
    • Joined on 03-03-2009, 8:51 PM
    • Posts 11

    Re: 301 Redirects with Joomla on IIS7

    Based on the samples at http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module/ , I modified the web.config to:

        <rewrite>
          <rewriteMaps>
            <rewriteMap name="StaticRedirects">
              <add key="/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html" value="/autotraded-newsletters/10-percent-per-month.html" />
            </rewriteMap>
          </rewriteMaps>
          <rules>
            <rule name="Security Rule" 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="SEO Rule">
              <match url="(.*)" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
                <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" />
            </rule>
            <rule name="Redirect Rule" stopProcessing="true">
              <match url=".*" />
              <conditions>
                <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
              </conditions>
              <action type="Redirect" url="{C:1}" appendQueryString="False" redirectType="Permanent" />
            </rule>
          </rules>
        </rewrite> 

    But when I go to /autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html , it just goes to that URL (I was expecting it to redirect to /autotraded-newsletters/10-percent-per-month.html, as per the rewrite map).

    This, by the way, is at placeholder site: http://beta.talkaboutthat.com/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html 

  • 09-13-2009, 2:41 PM In reply to

    • jtalbot
    • Not Ranked
    • Joined on 03-03-2009, 8:51 PM
    • Posts 11

    Re: 301 Redirects with Joomla on IIS7

    I tried a few more tests to try to understand what's going on.

    I added a page at http://beta.talkaboutthat.com/article.aspx , as per the article at http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module . I also added the following to the rewriteMap (see previous post in this thread):

    <add key="/old-article.aspx" value="article.aspx" />

    And that works properly; meaning, when I go to http://beta.talkaboutthat.com/old-article.aspx , I'm automatically redirected to http://beta.talkaboutthat.com/article.aspx .

    Thus, the redirect rule is working in general, the rewrite map is working in general, but is just not working for joomla seo'd url's.

    I also tried this rewrite map entry:

    <add key="/old-article.aspx" value="/autotraded-newsletters/10-percent-per-month.html" />

    That works (when I enter http://beta.talkaboutthat.com/old-article.aspx , I'm correctly redirected to http://beta.talkaboutthat.com/autotraded-newsletters/10-percent-per-month.html

    Finally, I tried:

    <add key="/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html" value="/article.aspx" />

    That DID NOT work. When I entered http://beta.talkaboutthat.com/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html I was NOT redirected to http://beta.talkaboutthat.com/article.aspx .

    So, there's something going awry when going from SEO Rule to Redirect Rule. I don't know what it is; as far as I know these rules are chainable, meaning the ouput of one becomes the in put of the other... The output of the previous rule should be http://beta.talkaboutthat.com/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html , which means it should be converted to http://beta.talkaboutthat.com/autotraded-newsletters/10-percent-per-month.html

     

  • 09-14-2009, 1:59 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Answered Re: 301 Redirects with Joomla on IIS7

    Try placing the "Redirect Rule" before the "SEO Rule". Most probably the "SEO Rule" rewrites the URL to index.php and hence the "Redirect Rule" does not match.

    http://ruslany.net
  • 09-14-2009, 4:18 PM In reply to

    • jtalbot
    • Not Ranked
    • Joined on 03-03-2009, 8:51 PM
    • Posts 11

    Re: 301 Redirects with Joomla on IIS7

    Hah, you're right. Thanks!

Page 1 of 1 (5 items)
Microsoft Communities