1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Help With My Web.config File (Canonical Issue)

Discussion in 'White Hat SEO' started by Davidnrog, Feb 19, 2015.

  1. Davidnrog

    Davidnrog Regular Member

    Joined:
    Apr 21, 2014
    Messages:
    219
    Likes Received:
    30
    Occupation:
    Owner, Designer, Entrepreneur, Marketeer..
    Location:
    Besides you
    I'm working on my new website which is facing some canonical error.
    I've moved my website to www.example.com from (without)example.com by using the code below

    (Note :fixed the www and no-www error)

    I want my website redirect's, when i type "www.example.com/index.php" to "www.example.com"

    "(i.e. I don?t want to have the ?index.php? portion visible in the address)"

    Code:
    <configuration> 
      <system.webServer> 
        <rewrite> 
          <rules> 
            <rule name="Redirect to WWW" stopProcessing="true"> 
              <match url=".*" /> 
              <conditions> 
                <add input="{HTTP_HOST}" pattern="^example.com$" /> 
              </conditions> 
              <action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" /> 
            </rule> 
          </rules> 
        </rewrite> 
      </system.webServer> 
    </configuration>


    Thank's

    Please Help..
     
  2. Davidnrog

    Davidnrog Regular Member

    Joined:
    Apr 21, 2014
    Messages:
    219
    Likes Received:
    30
    Occupation:
    Owner, Designer, Entrepreneur, Marketeer..
    Location:
    Besides you
    I'm still waiting to get some expert suggestion for this issue.
     
  3. tiyowan

    tiyowan Regular Member

    Joined:
    Aug 7, 2013
    Messages:
    251
    Likes Received:
    137
    Strange, why are you trying to remove index.php with a web.config file? Is your site in ASP.NET or is it in PHP?
     
  4. Davidnrog

    Davidnrog Regular Member

    Joined:
    Apr 21, 2014
    Messages:
    219
    Likes Received:
    30
    Occupation:
    Owner, Designer, Entrepreneur, Marketeer..
    Location:
    Besides you
    The website is in Php, I've implement the above code in my web.config When i visit to my site "http://www.example.com" or "http://www.example.com/index.php" With and Without index.php; it is presented with the exact same page, and having the same content and it resolve's at two different website url. I know it's potentially harmful for search engine ranking...
     
  5. Gillyrocker

    Gillyrocker Jr. VIP Jr. VIP

    Joined:
    Oct 10, 2013
    Messages:
    400
    Likes Received:
    58
    Occupation:
    Dreaming
    Location:
    BHW
  6. Gillyrocker

    Gillyrocker Jr. VIP Jr. VIP

    Joined:
    Oct 10, 2013
    Messages:
    400
    Likes Received:
    58
    Occupation:
    Dreaming
    Location:
    BHW
  7. tiyowan

    tiyowan Regular Member

    Joined:
    Aug 7, 2013
    Messages:
    251
    Likes Received:
    137
    If your website is in PHP, then why is there a web.config file? Web.config contains
    settings for ASP.NET web apps. If your site's in PHP use a .htaccess file to remove
    the index.php from the URL.

    EDIT: I pasted the .htaccess that I use:

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
     
    • Thanks Thanks x 1
    Last edited: Feb 20, 2015
  8. Davidnrog

    Davidnrog Regular Member

    Joined:
    Apr 21, 2014
    Messages:
    219
    Likes Received:
    30
    Occupation:
    Owner, Designer, Entrepreneur, Marketeer..
    Location:
    Besides you
    As per my knowledge .haaccess is for those website which are on Apache server. My website is on the flexible (IIS) 8 Windows Server.
     
    Last edited: Feb 20, 2015
  9. tiyowan

    tiyowan Regular Member

    Joined:
    Aug 7, 2013
    Messages:
    251
    Likes Received:
    137
    That's right. So it's a PHP site on an IIS server, that's a bit unusual but whatever.

    Here you go:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <defaultDocument enabled="true">
                <files>
                    <add value="index.php" />
                </files>
            </defaultDocument>
            <rewrite>
                <rules>
                    <rule name="cleanurls" enabled="true" stopProcessing="true">
                        <match url=".*" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
     
    • Thanks Thanks x 1