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
-
Htaccess mod rewrite from server address
Hi there, I'm not massively experienced with creating mod rewrite rules and I'm worried I've got this wrong as its slightly different to what I'm used to. The web dev and content creators were working on http://5.10.105.45/~isea/ to create content. I want to redirect all URL's to www.iseasurfwear.co.uk. This is what I've written //Rewrite to www
Technical SEO | | BlueTree_Sean
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^5.10.105.45/~isea/[nc]
RewriteRule ^(.*)$ http://www.iseasurfwear.co.uk/$1 [r=301,nc] Can anyone tell me if this is correct?0 -
Url rewrite subfolder
Hi, How can i rewrite example.com/example1/example2/example3 to example.com/example3 And is there tools or software that can generate url rewrite... (not a plugin) Thanks !
Technical SEO | | bigrat950 -
Is it necessary to 301 rewrite /index.php to /?
Hi, We have build a lot of external link to http://www.oursite.com/ Do I have to do a 301 redirect from http://www.oursite.com/index.php to http://www.outsite.com/? Thanks
Technical SEO | | LauraHT0 -
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 -
Proper structure for site with multiple catagories of same products
Hi, we have products (trophies and awards) that can be catagorized in many ways. Using Award Medals as an example: - Medals by type: 1 1/2", 2", etc. - Medals by sport Baseball, Basketball, Cheer - Medals by Style Color, Gold, Silver, Bronze Right now, we have an Award Medals section off of our home page. The section has a decent page rank, but should be much better (I think). My guess is that we are loosing page range since we have separate sections with the groups above as we want our customers to be able to find the medals easily. Unfortunately, when we setup our site 10 years ago, we organized by type and this is what is hanging off the home page. The other groupings we added more recently. I have attached a snap shot of what the sections look like. We would like customers to find an individual medal when they do a Google search. For example a search for Baseball Medals. In Goggle, they likely would not search for 1 1/2" medals. My question is this: Can we keep the same structure we have today (to enable customer flexibility) but improve page rank and also have the sections like basball medals rank well? I have thought about using canonical tags, but the pages are not the same - in one case it is all baseball medals, in another it is all 1 1/2" medals, etc. Thanks for your help!!
Technical SEO | | trophycentraltrophiesandawards0 -
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 -
Properly Moving Blog from Index to its Own Page
Right now I have a website that is exclusively a blog. I want to create pages outside of the blog and move the blog to a page other than the index file e.g.) from domain.com to domain.com/blog I will have the blog post pages stay in the root directory. e.g.) domain.com/blog-post Any suggestions how to properly tell SE's and other websites that the blog has moved?
Technical SEO | | Bartell0 -
Rel=Canonical to Rewrite or original URL?
Working with a large number of duplicate pages due to different views of products. Rewriting URLs for the most linked page. Should rel=canonical point to the rewritten URL or the actual URL? Is there a way to see what the rewritten URL is within the crawl data? I was taking the approach of rewriting only the base version of each page and then using a rel=canonical on the duplicate pages. Can anyone recommend a better or cleaner approach? Haven't seen too many articles on retail SEO when faced with a less than optimized CMS. Thanks!
Technical SEO | | AmsiveDigital0