Change Open Realty URLs to Remove .html Suffix

It is possible to change the URLs on your Open Realty installation to remove the .html suffix.  In fact, it's simple.  Here's how. I assume you are already running a working version of Open Realty and have set SEO urls on in the config control panel and have that working.

First of all, you need to modify a core file, which means that you are potentially creating a more troublesome upgrade experience should you choose to upgrade your installation in the future. (See pbflash's comment here) So, what's the file? 

The place to start is include/class/template/ - you'll need to modify that at the same time that you modify your .htaccess file, because these need to be in sync.  If you sort of or totally know what I'm talking about, you'll be fine.  If you totally don't have a clue what I'm talking about, do not try this modification because it's too hard for you.

Assuming that you are semi-following, you need to find the URLs you want to change in .htaccess and change them from what you don't like to what you do like.  For instance, I changed agents.html to agents.  Also, I changed some of the underscore characters to hyphens.  For each of the modifications I made in .htaccess, I had to find the place in the source code of the file and also change it there (so that the URL built by the template engine is expressed in the desired form, like "agents", instead of in the old, undesired form, like "agents.html"). 

Here are the rest of the lines from my .htaccess file:

RewriteRule search index.php?action=searchpage [L]
RewriteRule search-results index.php?action=searchresults [L]
RewriteRule agents index.php?action=view_users [L]
RewriteRule view-favorites index.php?action=view_favorites [L]
RewriteRule calculator index.php?action=calculator&popup=yes [L]
RewriteRule saved-searches index.php?action=view_saved_searches [L]
RewriteRule listing_image_([0-9]*).html index.php?action=view_listing_image&image_id=$1 [L]
RewriteRule logout index.php?action=logout [L]
RewriteRule member-signup index.php?action=signup&type=member [L]
RewriteRule agent-signup index.php?action=signup&type=agent [L]
RewriteRule member-login index.php?action=member_login [L]

and here are the lines I changed from the file:

$this->page = str_replace('{url_index}', $config['baseurl'] . '/', $this->page);
$this->page = str_replace('{url_search}', $config['baseurl'] . '/search', $this->page);
$this->page = str_replace('{curley_open}', '{', $this->page);
$this->page = str_replace('{curley_close}', '}', $this->page);
$this->page = str_replace('{url_search_rental}', $config['baseurl'] . '/rental-search', $this->page);
$this->page = str_replace('{url_search_results}', $config['baseurl'] . '/search-results', $this->page);
$this->page = str_replace('{url_view_agents}', $config['baseurl'] . '/agents', $this->page);
$this->page = str_replace('{url_view_favorites}', $config['baseurl'] . '/view-favorites', $this->page);
$this->page = str_replace('{url_view_calculator}', $config['baseurl'] . '/calculator', $this->page);
$this->page = str_replace('{url_view_saved_searches}', $config['baseurl'] . '/saved-searches', $this->page);

To change some additional URLs (for instance the urls with numbers in the urls) requires some additional changes I may make later.

As a special bonus, I'll also include another line I added at the same time to the top of my .htaccess file - this line always changes to, removing www. from all URLs. I do this with all my sites. Don't add the line if you like the www. prefix for your domains! Obviously this is unrelated to the .html suffixes and will work with any site - not just open realty sites. It's

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]