The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. How to properly abandon mod rewrite?

    How to properly abandon mod rewrite?

    Technical SEO Issues
    2 2 649
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mynewco
      mynewco last edited by

      Hi,

      We've done mod-rewrite to our .php files to show .htm files several years ago for SEO purposes.

      My question is, doing this has become a hassle for adding new pages, etc. and I'd like to make a clean break with the .htm and move to their real file names and or directories (e.g. company.htm --> /company/ ).

      What kind of ranking penalty am I looking at if we switch? We're a small company with billion dollar competitors so a rank loss would be fairly devastating.

      I assume I'd need to do 301 redirects for all of the old file names (obviously yes for the change from page to directories) but for each individual page?

      Thanks,

      Matt

      1 Reply Last reply Reply Quote 0
      • Nick_Ker
        Nick_Ker last edited by

        Maybe I am missing something, but wouldn't a rewrite that removes all the .php instances solve this problem site-wide? Or are you doing it file by file and leaving some pages as-is?

        Something like this in your .htaccess should do it:

        to remove php:

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule ^(.*)$ $1.php

        or to change to htm site-wide:

        RewriteEngine on
        RewriteBase /
        RewriteRule ^([^.]+).htm$ $1.php [L]

        Another way is to name the files with .htm and use this in htaccess to send htm through your PHP handler:

        AddType application/x-httpd-php htm html php
        AddHandler application/x-httpd-php .htm .html

        If you use rewrites like those, you won't be able to also use 301s for the affected URIs as it would probably create a redirect loop.

        In a perfect world, you should 301 redirect any page that changes if you stop using the php to htm rewrites. If there are simply too many for this to be practical, you could just redirect the most important pages and leave out any that may not have very many inbound links pointing to it. What I will often do in cases like this is set up the redirects for the important pages, then keep an eye on Google Webmaster Tools. Webmaster Tools will show you the 404 errors and where they found the links. Then you can pick the ones that have a lot of links and 301 those a few at a time. Tedious, but if you do that in your spare time, eventually you will get them all fixed.

        If you can implement a "set it and forget it" rewrite so you don't have to add a new rewrite for each file, you won't have to worry about 301 redirecting all those old pages.

        Otherwise, there really shouldn't be any major loss of rank from dropping the file types.

        All that said, there isn't much of a reason to remove the file type extensions, other than to shorten addresses by a few characters and just look a little cleaner.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        • Magento Rewrite Issue
          Everett
          Everett
          0
          3
          88

        • Url rewrite subfolder
          TheeDigital
          TheeDigital
          0
          6
          150

        • Htaccess Rewrites
          Klement69
          Klement69
          0
          4
          316

        • Mod rewrite question
          ahirai
          ahirai
          0
          4
          279

        • Duplicate Content - Home Page even wth Mod Rewrite 301
          Titan552
          Titan552
          0
          4
          1.0k

        • How to skip all rewrite rules
          ChristopherGlaeser
          ChristopherGlaeser
          0
          3
          598

        • Mod Rewrite question to prevent duplicate content
          kat2
          kat2
          0
          5
          635

        • URL Rewrite
          oznappies
          oznappies
          0
          4
          1.0k

        Get started with Moz Pro!

        Unlock the power of advanced SEO tools and data-driven insights.

        Start my free trial
        Products
        • Moz Pro
        • Moz Local
        • Moz API
        • Moz Data
        • STAT
        • Product Updates
        Moz Solutions
        • SMB Solutions
        • Agency Solutions
        • Enterprise Solutions
        • Digital Marketers
        Free SEO Tools
        • Domain Authority Checker
        • Link Explorer
        • Keyword Explorer
        • Competitive Research
        • Brand Authority Checker
        • Local Citation Checker
        • MozBar Extension
        • MozCast
        Resources
        • Blog
        • SEO Learning Center
        • Help Hub
        • Beginner's Guide to SEO
        • How-to Guides
        • Moz Academy
        • API Docs
        About Moz
        • About
        • Team
        • Careers
        • Contact
        Why Moz
        • Case Studies
        • Testimonials
        Get Involved
        • Become an Affiliate
        • MozCon
        • Webinars
        • Practical Marketer Series
        • MozPod
        Connect with us

        Contact the Help team

        Join our newsletter
        Moz logo
        © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
        • Accessibility
        • Terms of Use
        • Privacy