locked
Need help. Nothing seems to work. RRS feed

  • Question

  • User-1761619084 posted
    So here is the deal. I'm building a new website (http://wawg.cap.gov/new/) and trying not to mess up the old site in the mean time.
    I'm not sure how to check, but I'm fairly sure the server is running ISS7. I know that FastCGI is running. The end goal is to get a wordpress style pretty url working via web.config. Here is what I've found via internet searching that I should be using:

    http://wawg.cap.gov/new/web.config.txt

    There was no existing web.config and I'm not sure the web.config is being loaded.

    Anyone have any ideas for me to try?
    Saturday, March 19, 2011 6:07 PM

Answers

  • User-176674611 posted

    According to your htaccess settings, the corresponding rule is like following:

    <rewrite>
      <rules>
        <rule name="WordpressRewrite" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>

    However, this doesn't make difference from the rule in previous post. I notice you have error page settings in your htaccess file. Would you please add the corresponding setting in web.config to see if this helps, the setting looks like:

    <system.webServer>
      <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
      </httpErrors>
    </system.webServer>

    Thanks.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, March 25, 2011 5:55 AM

All replies

  • User-655144444 posted

     this is the url rewrite rule for wordpress under IIS7

    <system.webServer>
        <rewrite>
          <rules>
            <rule name="wordpress" patternSyntax="Wildcard">
              <match url="*"/>
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
              </conditions>
              <action type="Rewrite" url="index.php"/>
            </rule>
          </rules>
        </rewrite>
    </system.webServer>

    Actually if your IIS set to allow custom rules override, you only need to configure the permalinks as you like from wp admin, the above rules will be auto generated just like .htaccess

    Saturday, March 19, 2011 9:15 PM
  • User-1761619084 posted
    That's helpful, but two things.

    First, this isn't actually a Word Press site, so nothing will be auto-generated. Instead, I just need wordpress style prety URLs.

    Second, I unfortunately don't have direct IIS access. :(
    Saturday, March 19, 2011 9:22 PM
  • User-655144444 posted

     I'm little confused. what do you mean "wordpress style prety URLs."? the above are standard rules for wordpress url rewrite and you can define any style url format as you liked. If you're from a hosting environment, you might need to check with hosting support if the iis allow custom override.

    Saturday, March 19, 2011 9:45 PM
  • User-1761619084 posted
    Yes, the code is helpful and will do the redirect properly (if I ever get it to work...), but my server doesn't appear to be loading the web.config file at all.

    I'll see if I can get in contact with my hosting provider.

    Thanks!!
    Saturday, March 19, 2011 10:08 PM
  • User-176674611 posted

    Hi,

    Could you please elaborate the detail of this issue? Can you access the pages in your site succesfully? If not, what is the status and substatus code in iis log?

    Thanks.

     

    Thursday, March 24, 2011 9:22 PM
  • User-1761619084 posted
    I can access the home page (located in /new/app/pages/home.php) as if it were in the root folder of this project (/new/) but links to any other pages (/located in /new/app/pages/aerospace-education.php) return a "page cannot be found" error. Home Aerospace Education I do not think I have access to IIS errors.
    Thursday, March 24, 2011 10:26 PM
  • User-176674611 posted

    Is "aerospace-education" one of the folders under your site? If it isn't, you will need to set rewrite rule for the request, otherwise this will lead to a 404 error.

    If you have already set the rewrite rules, would you please post your rules here? Also the failed request tracing logs will show more information on these issue.

    Troubleshooting Failed Requests Using Tracing in IIS 7
    http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-7/

    Thanks.

     

    Thursday, March 24, 2011 10:38 PM
  • User-1761619084 posted

     I am using the rewrite posted above. The way I want it to work, it would go to first the page and then to the folder afterwards if it doesn't find the file in the root folder.<br><br>

     

    I wish I could give you the IIS logs, but I don't have access to IIS. :( Is there a way to print them out in my PHP file?

    Thursday, March 24, 2011 11:41 PM
  • User-176674611 posted

    According to the rule, it rewrites this kind of requests to "index.php" which locates at root of your site(I assume you add the rule at root web.config of your site). Could you please check whether the "index.php" file exists in the root directory of your site?

    Thanks.

    Friday, March 25, 2011 12:01 AM
  • User-1761619084 posted

     Here is the equivalent .htaccess I am trying to achieve.

    <IfModule mod_rewrite.c>
       Options +FollowSymLinks
        RewriteEngine on
        RewriteBase /
        
        #This will stop processing if it's images    
        #RewriteCond %{REQUEST_URI} !^/pages/.*$    
        #RewriteCond %{REQUEST_URI} ^(.*css|jpe?g|gif|png|js)$    
        #RewriteRule ^(.*)$ /pages/$1 [L]
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.

        ErrorDocument 404 /index.php
    </IfModule>

     Everything is routed THROUGH index.php to the file. I'm unfortunately no expert on this because my boss made the htaccess but we don't have any IIS Servers at work. 

    Friday, March 25, 2011 12:09 AM
  • User-176674611 posted

    According to your htaccess settings, the corresponding rule is like following:

    <rewrite>
      <rules>
        <rule name="WordpressRewrite" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>

    However, this doesn't make difference from the rule in previous post. I notice you have error page settings in your htaccess file. Would you please add the corresponding setting in web.config to see if this helps, the setting looks like:

    <system.webServer>
      <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />
      </httpErrors>
    </system.webServer>

    Thanks.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, March 25, 2011 5:55 AM
  • User-1761619084 posted

     Thanks for the response! That appears to have helped in the home directory.

    What method would you suggest to make the rules only apply to the one directory?  Should I just change "/index.php..." to "/new/index.php..." or is there a better way to do it?

     For reference, the current  web.config is posted here: http://wawg.cap.gov/new/web.config.txt

     

    Thanks again for the help!

    Saturday, April 2, 2011 4:36 PM
  • User-1761619084 posted
    Does anyone know how to restrict this to one subfolder? I've tried everything I mentioned above and even tried putting the web.config inside the folder, nothing works... Anyone? Please?
    Friday, April 22, 2011 4:35 PM
  • User2126617008 posted
    Thanks Topspy that URL Re Write for wordpress for IIS7 worked like a dream been trying to get that right for months thanks so much!
    Sunday, April 24, 2011 6:51 AM