Using ModRewrite
Let’s say you have just re-designed a website and during the process you were forced to change some filenames in the new site from what they were in the existing website. For example, about.htm is now called about.php in the new site structure. Normally you would be forced to endure having a dead link in Google until your new filename get’s crawled or updated from your sitemap.xml. This can sometimes take weeks if not longer.
A quick way around this is to use the ModReWrite Engine to “re-route” filenames to new filenames. This also comes in handy if you have a lot of external websites or clients that link back to specific pages in your website. To setup ModRewrite Engine, simply create or edit your .htaccess file to have the following sample code: (of course change this to match your filenames, etc.)
1: Options +FollowSymLinks
2: RewriteEngine On
3: RewriteRule ^index.html http://www.yourwebsite.com/index.php
4: RewriteRule ^directory_name/index.html http://www.yourwebsite.com/directory_name/index.php
Using mod_rewrite in Apache
I created a Real Estate solution for a client a while back in php and it has worked well for them but once the site launched we noticed that it wasn’t getting crawled by the search engines as well as we would have liked for it to so I did a little research. I knew that typically data called in from a database dynamically presented a problem when it came to getting the best SEO performance.
I asked a few developers this past year at HostingCon about this and they suggested I look into Mod Rewrite in apache and see if that wouldn’t help out. I checked it out and so far the results have been phenomenal for the client. Here’s what I did in case any of you run into a smilar situation. I first created an .htaccess file to redirect to a “home page”, in this case it’s called index2.php. Next I did a rewrite for the dynamically generated pages. The .htaccess file looks like this:
Options +FollowSymLinksRewriteEngine OnRewriteRule ^index2.php prime-listings/index_view.php?editid1=1RewriteRule ^prime-listings/lakefront_homes.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Lakefront+Homes&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/lakefront_lots.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Lakefront+Lots&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/lakeview_homes.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Lakeview+Homes&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/lakeview_lots.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Lakeview+Lots&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/river_properties.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=River&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/residential_properties.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Residential&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/residential_lots.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Residential+Lots&SearchOption=Equals&SearchField=RewriteRule ^prime-listings/commercial_properties.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Commercial&SearchOption=Equals&SearchField=typeRewriteRule ^prime-listings/farm_land.php prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=acreage&SearchOption=Contains&SearchField=
So now for example, instead of using http://www.greersferryrealestatecenter.com/prime-listings/prime_listings_list.php?a=search&value=1&SearchFor=Residential&SearchOption=Equals&SearchField=type as a link, I just use this: http://www.greersferryrealestatecenter.com/prime-listings/residential_properties.php. This is apparently more favorable to the search engines.





