How to properly abandon mod rewrite?
-
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
-
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.phpor 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 .htmlIf 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.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Magento Rewrite Issue
Moz's Crawler has thrown up a bunch of crawl issue for my site.The site is a magento based site and I recently updated the themes so some routes may have have become redundant. Moz has identified 289 pages with Temporary Redirect. I thought magento managed the redirects if I set the "Auto-redirect to Base URL" to Yes(301 Moved permanently). But this is enabled on my store and I still get the errors. The only thing I could think of was to add a Robots.txt and handle the redirection of these links from here. But handling redirection for 289 links is no mean task. I was looking for any ideas that could fix this without me manually doing this .
Technical SEO | | abhishek19860 -
Am I doing SEO test properly?
Hello, I just created a page for researching the impact of social signals on Google ranking (in Italy). Page was not optimized (one internal backlink, no other external/internal links, keyword repeated 4 or 5 + h1 h2, no alt tags), and only social signals are being stimulated (through votes). The domain is 2 months old and is already positioned for few relevant keywords, but from 2 page down. My question is: am I doing right? Is this a good way to proceed? And if not, what I should do instead? Thank you for an advice. Eugenio
Technical SEO | | socialengaged0 -
How to properly do reviews with Rich Text Snippets
I am trying to find out the best way to do this. Do you use hreview? Thanks,
Technical SEO | | netviper0 -
Localization without proper address?
Hi Mozzers, recently I received a project to promote a hotel website in a third world country. They have no street names, no landline phone, no zip-code. So far I tried to give a good address description in all social networks and on the homepage (footer) and signed into hotel directories. Suddently a new website of another hotel came up on google and made it up to number 1. They put a fake telefon number (landline) on the website. Is that a good idea of localizing a business? Do you have recommendations for me how to enhance. Thanks
Technical SEO | | reisefm0 -
Proper method of consolidating https to http?
A client has an application area of the site (a directory) that has a form and needs to be secured with ssl. The vast majority of the site is static, and does not need to be secured. We have experienced situations where a visitor navigates the site as https which then throws security errors. We want to keep static visitors on http; (and crawlers) and only have visits to the secure area display as ssl. How is this best accomplished? Our developer wants to add a rule to the global configuration file in php that uses a 301 redirect to ensure static pages are accessed as http, and the secure directory is accessed as https. Is the the proper protocol? Are there any SEO considerations we should make? Thanks.
Technical SEO | | seagreen0 -
Is the seomoz on-page factor :Appropriate Use of Rel Canonical working properly?
I have a word press site with a rel canonical plug in. The rel="canonical" href= is there and the url in there works and goes to the actual page.So why does the seomoz keep giving the warning: Appropriate Use of Rel Canonical
Technical SEO | | CurtCarroll0 -
Htaccess Rewrites
Hi, I'm battling with duplicate content and would love to fix some redirections in my htaccess file: 1. I'm trying to use the www version of my site via 301 2. I'm trying to remove ALL /index.php from my url's I currently have the following code, but my home page /index.php is still not redirecting to the root? Options +FollowSymLinks
Technical SEO | | Klement69
Options +Indexes <ifmodule mod_rewrite.c="">RewriteEngine On
#RewriteBase / RewriteCond %{HTTP_HOST} ^funeralcoverfinder.co.za$ [NC]
RewriteRule ^(.*)$ http://www.FuneralCoverFinder.co.za/$1 [R=301,NC,L] RewriteCond %{QUERY_STRING} base64_encode[^(]([^)]) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]s)+cript.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule .* index.php [F] RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]|.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]</ifmodule> Any Advice? - Thanks so much!0 -
Need Help with MAGENTO - URL rewrite
Hello... Hopefully a Magento expert will stumble across this question and help me out. I have noticed that my site is no longer as prominent as it once was for specific product pages... I am looking for help in rewriting the URL's for the product pages. I want it to have xyz.com/product (which exists if you hard code it into the site) If you wind up on the product by clicking throught the categories the url looks like: xyz.com/category/subcategory/product. Does anyone know how to make it so when you land on a product page it is just xyz.com/product ? My Site is : http://goo.gl/JgK1e Thanks for the help...
Technical SEO | | Prime850