views:

3444

answers:

4

Hello,

I have Joomla 1.5.9 running with php 5.2.8, mySQL 5.1.31 on IIS7 on a vista 64 dev box. I have both SEO Settings "Search Engine Friendly URLs" and "Use Apache mod_rewrite" working correctly.

I'm also setting up a hosted site (with www.mochahosting.com). They use slightly older versions of the same software: Joomla 1.5.5, php 5.2.6, mySQL 5.0.4x. They also use IIS7, but running on Windows 32.

I can't get either of the SEO settings to work on the hosted site (I have gotten the SEO settings to work on my local machine, with pretty much the same configuration). Let's start with "Search Engine Friendly URLs" only to keep things simple.

Also, I don't yet have a domain name, so I use a hosts file alias to get to the site. I don't expect anyone to go through that trouble to answer my question, so I'll just describe the issue and hope I do a good enough job that people can understand what's going on. I'll use http://nodomainyet.com/joomla156_mx as the base URL (i.e., the joomla home page) for the purpose of this question. Yes, this does imply that Joomla is installed in a subdirectory -- I'm not sure if this is a problem or not (it's not a problem on my dev box).

On to the problem.

Turning on "Search Engine Friendly URLs" causes http://nodomainyet.com/joomla156_mx to generate a 404 ("Component not found"). In the 404 error page there is a link that goes to http://nodomainyet.com/joomla156_mx/index.php -- and that link works. If I turn off "Search Engine Friendly URLs" then both http://nodomainyet.com/joomla156_mx and http://nodomainyet.com/joomla156_mx/index.php work. So it seems that turning on "Search Engine Friendly URLs" causes the "automatic redirecting" of http://nodomainyet.com/joomla156_mx to http://nodomainyet.com/joomla156_mx/index.php to stop working...

Now, if I go to http://nodomainyet.com/joomla156_mx/index.php and from there navigate to the various main menu links (I'm only using the default joomla site that gets installed with a new Joomla instance), then everything works fine. It's just going to http://nodomainyet.com/joomla156_mx that doesn't work. It's worth noting that the "home" link that's in the main menu goes to http://nodomainyet.com/joomla156_mx by default.

I've compared the output of phpinfo on the host to that of my dev box and couldn't see any differences that would cause this issue...

Turning on the second SEO setting -- "Use Apache mod_rewrite" -- does not solve the problem (one would think that it might, since the purpose of that setting is to get rid of index.php in the URL).

The "Search Engine Friendly URLs" usually seems pretty trivial to get to work -- it doesn't require a web.config and rewrite rules... I'm not sure what could possibly cause it to go wrong.


Update - 2009-03-03

I thought maybe it was a bad idea to only turn on the first SEO setting ("Search Engine Friendly URLs") from ("Use Apache mod_rewrite") (even though I can just turn on "Search Engine Friendly URLs" by itself on my local machine and it works fine). So I tried a few more experiments

I thought perhaps the problem was that URL rewriting wasn't setup properly in IIS7 on the host. I did the (first) test file described in http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module and that worked -- so that means URL rewriting is working.

Then I thought perhaps the problem is that the rewrite rules that one sees everywhere for Joomla on IIS7 need to be rewritten to take into account the subdirectory. Like I said above, the SEO settings are working fine on my local machine. Joomla is also installed in a subdirectory, and everything is working fine. Nevertheless, I tried to modify the rewrite rule from

<rewrite>
    <rules>
        <rule name="Imported Rule 1" enabled="true">
            <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="{SCRIPT_NAME}" negate="true" pattern="^/index.php" ignoreCase="false" />
                <add input="{SCRIPT_NAME}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
            </conditions>
            <action type="Rewrite" url="index.php" />
        </rule>
    </rules>
</rewrite>

to

<rewrite>
    <rules>
        <rule name="Imported Rule 1" enabled="true">
            <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="{SCRIPT_NAME}" negate="true" pattern="^/joomla156mx/index.php" ignoreCase="false" />
                <add input="{SCRIPT_NAME}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
            </conditions>
            <action type="Rewrite" url="joomla156mx/index.php" />
        </rule>
    </rules>
</rewrite>

(i.e., prepending the directory name to the condition and action). That didn't make a difference. Now, I'm completely new to rewrite rules so I might have screwed up something.

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? But, again, this is all working fine on my local box with plain old rewrite rules, so I may be barking at the wrong tree.

Thanks for the help!

+1  A: 

The last steps on this page walk through Enabling Search Engine Friendly URLs.

By default Joomla uses query string parameters for all the links URLs it generates for your web site. This behavior can be changed by enabling what is called "Search Engine Friendly URLs" in Joomla. However, this feature relies on the URL rewriting functionality to be available on the web server. IIS 6.0 does not have URL rewriting capabilities, so you could use one of the third party URL rewriting products, such as ISAPI_Rewrite or Ionics ISAPI Rewrite Filter. IIS 7.0 has URL rewriting support, which can be enabled by installing Microsoft URL Rewrite Module for IIS 7.0. The following instructions describe how URL Rewrite Module for IIS 7.0 can be used to enable Clean URLs in Joomla.
First, you will need to download and install Microsoft URL Rewrite Module. Once it has been installed, create and open a web.config file located in C:\inetpub\wwwroot\Joomla folder. Paste the following XML code into this file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <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>
 </system.webServer>
</configuration>

Save the web.config file and then open web browser and logon to the Joomla administrator console at http://localhost/joomla/administrator/ . Once logged on, go to Site --> Global Configuration menu configure SEO settings as below:

  • Search Engine Friendly URLs - Yes
  • Use Apache mod_rewrite - Yes
  • Add suffix to URLs - No
  • Save configuration by clicking on "Apply" and then browse to http://localhost/joomla/ . You will see that now all links in Joomla pages have URLs without query string parameters and if you click on any of these links the server will return correct response:

    notandy
    Thanks for the answer. However, I've already followed similar instructions on both my local machine and on the hosted site; it's working on my local machine but not the hosted site... So I need a bit more details on how to diagnose this on the hosted site.
    Jimmy
    +1  A: 

    It turns out the problem was that the hosting company wasn't using FastCGI to run php. Even if it says "Server API = CGI/FastCGI" when running phpinfo(), that is NOT ENOUGH to guarantee that fastcgi is being used.

    What's wrong with using CGI or ISAPI? They both have issues with the php variable _SERVER["REQUEST_URI"] , which joomla SEO uses.

    See my other question for how to figure out for sure if FastCGI is being used or not: http://stackoverflow.com/questions/609044/how-to-know-for-sure-if-fastcgi-is-being-used-to-run-php-scripts

    Jimmy
    A: 

    Hi,

    I have a website www.carooolglobal.com, all the features work fine with all the SEO setting set to No.

    If i set any of the SEO settings to Yes, and perform a search from search form left side on home page, it is showing the results on index.php properly.but when i click on the name link from the search result, it should open the profile of the person in pop up window, but pop window shows

    You may not be able to visit this page because of:

    an out-of-date bookmark/favourite a search engine that has an out-of-date listing for this site a mistyped address you have no access to this page The requested resource was not found. An error has occurred while processing your request. Please try one of the following pages:

    Home Page

    If difficulties persist, please contact the System Administrator of this site.

    I am clueless

    Regards Kislay

    A: 

    I'm not sure if this was covered yet, I looked but I'm good a missing things.

    If you're have problems with your search engine friendly links, go into your folder where joomla is installed, and rename your htaccess.txt file to .htaccess

    This should solve the 404 problem.

    Dan