Sun Nov 29 21:50:33 PST 2015

Exchanging Path1 for Path2 With an .htaccess File

I found that my site's Google search box (implemented a while back using a form to employ a Google search), returned results that looked promising but actually all pointed to URLs that contained the initial string 'blog' rather than 'data'. Evidently the Google index was elderly...

...I had recently decided to replace the string 'blog' with the string 'data' - (the idea behind this change was go disguise the fact that I use Nano-Blogger to prepare the site's pages!). Anyway, my initial way of handling the switch over from 'blog' to 'data' was to add a line in my .htaccess file to send requests for 'blog' pages to the index for the 'data' section of the web site. I hadn't realized that the line in question was sending everything only to the main index of the site - not very useful.

A little experimentation with .htaccess rules though yields a more correct rule which changes URLs with 'blog/' into URLs which have 'data/' which is what I needed. Here is the necessary line for the .htaccess file:

RewriteRule ^blog/(.*) http://www.themolecularuniverse.com/data/$1 [L]

For the record the previous (failing) .htaccess line was:

RewriteRule ^blog/* http://www.themolecularuniverse.com/data/$1

I am not sure where the incorrect line came from - but I am learning that things in parentheses in .htaccess files are important...

Comments are closed


If you would like to get in touch with me, please mail zfs at themolecularuniverse.com

recent comments

Posted by ZFS | Permanent link | File under: blogging
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]