Removing a Part of A URL Using A Rewrite Rule

I was given this simple task to redesign a site. The site was developed using plain HTML and CSS so what I've suggested is to use drupal inorder to speed up the redesign and at the same time make it easy for maintenance.

First thing I did was installed drupal in a subfolder so the URL was http://domain.com/subfolder/. I couldn't install drupal in the root directory since there are other files there and I might probably overwrite those. Another thing is that the client wanted to also use wordpress in the site and it's in the folder /blog/. So the only solution for me was to create a rewrite rule wherein when a visitor goes to http://domain.com, it would be similar as to going to http://domain.com/subfolder/ although the URL on the client browser won't change. Anyways, enough of chitchat. Here's what I added in the .htaccess file.


RewriteEngine on
RewriteCond $1 !^(drupal|images|blog|downloads)
RewriteRule ^(.*)$ /drupal/$1 [L]

I guess it's simple. Basically, all requests are directed to the URL /drupal/ except for URL's with drupal/, images/, blog/, or downloads/ on them.

Yeah!

3 comments:

  Laurence

March 27, 2009 at 10:40 PM

is that same as redirecting url stuff nold?
nax asteg

  Arn

March 30, 2009 at 1:35 PM

steeg! Haha Yes, it is a redirect! An internal one to be specific.. :-)

  Unknown

July 12, 2009 at 8:33 AM

/blog? prang familiar...hehe.. astig tlga si arn arn..galing2x... saludo ako sa kanya..