SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I have a 301 redirect to non-www, but www pages still getting views.

    I have a 301 redirect on my htaccess files, but my analytics show that some www page were being hit. Sometimes i get errors that pages were not found by google. These are my results from today... i hope they show up right.

    When I accesss my google webmaster tools I see some of my urls all mixed up.

    mahes that are supposed to be like http://bootcamp4me.com/meps/ are showing up as /meps/http://www.bootcamp4me.com

    here is a portion of my stats from yesterday... I see a trailing slash at the beginning for some reason.


    /recruits/military-pay-chart.html
    283 7.62%
    2.
    /http://www.bootcamp4me.com
    256 6.90%
    3.
    /meps/http://www.bootcamp4me.com
    254 6.84%
    4.
    /branches/us-navy-boot-camp/http://www.bootcamp4me.com
    212 5.71%
    5.
    /branches/us-navy-boot-camp/rtc-chain-of-command.html
    190 5.12%
    6.
    /branches/army-basic-training/http://www.bootcamp4me.com
    174 4.69%
    7.
    /asvab-test/http://www.bootcamp4me.com
    172 4.63%
    8.
    /branches/http://www.bootcamp4me.com

    here is the htaccess code that I am using

    Code:
    <IfModule mod_headers.c>
      Header set X-UA-Compatible "IE=Edge,chrome=1"
      # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
      <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
        Header unset X-UA-Compatible
      </FilesMatch>
    </IfModule>
    
    
    <IfModule mod_deflate.c>
    
      # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
      <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
          SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
          RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
      </IfModule>
    
      # Compress all output labeled with one of the following MIME-types
      <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE application/atom+xml \
                                      application/javascript \
                                      application/json \
                                      application/rss+xml \
                                      application/vnd.ms-fontobject \
                                      application/x-font-ttf \
                                      application/xhtml+xml \
                                      application/xml \
                                      font/opentype \
                                      image/svg+xml \
                                      image/x-icon \
                                      text/css \
                                      text/html \
                                      text/plain \
                                      text/x-component \
                                      text/xml
      </IfModule>
    
    </IfModule>
    
    
    # ----------------------------------------------------------------------
    # Expires headers (for better cache control)
    # ----------------------------------------------------------------------
    
    
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif A31536000
        ExpiresByType image/jpg A31536000
        ExpiresByType image/jpeg A31536000
        ExpiresByType image/png A31536000
        ExpiresByType image/bmp A31536000
        ExpiresByType text/css A31536000
        ExpiresByType text/javascript A31536000
        ExpiresByType application/javascript A31536000
        ExpiresByType application/x-javascript A31536000
    </IfModule>
    
    
    
    <IfModule mod_headers.c>
      Header unset ETag
    </IfModule>
    
    
    FileETag None
    
    
    # ----------------------------------------------------------------------
    # Start rewrite engine
    # ----------------------------------------------------------------------
    
    # Turning on the rewrite engine is necessary for the following rules and
    # features. FollowSymLinks must be enabled for this to work.
    
    <IfModule mod_rewrite.c>
      Options +FollowSymlinks
    # Options +SymLinksIfOwnerMatch
      RewriteEngine On
    # RewriteBase /
    </IfModule>
    
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    
    
    ErrorDocument 404 /404.html
    Can anyone please help me with my issues.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    What's up, Doc?

    Okay, you're not a webmaster because you've abused your .htaccess file significantly.

    First, and this one gets a "Standard Rant" is the use of <IfModule> tests.

    [standard rant #4]
    The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> ... </IfModule> wrapper is the same thing in the webmaster world. DON'T BE AN IDIOT! If you don't know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache's resources (and should NEVER be allowed on a shared server).
    [/standard rant #4]

    No, I'm not calling you an idiot, just explaining that no webmaster would ever abuse a server with MULTIPLE <IfModule> (server) tests for EVERY file request. In any case, all that @#$% is likely in the httpd.conf where it belongs.

    Second, FollowSymLinks is ALSO probably set in the httpd.conf.

    Third, what is your specification? If it's to remove www from your URLs, then your code is inhibited from this with the !=on conditional test.

    Code:
    RewriteEngine on
    
    # Remove www
    # RewriteCond %{HTTPS} !=on is NOT necessary
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •