URL Rewriting Fun Wednesday, August 25, 2010

A new addition to my blog that is pretty neat is how I'm creating my URLs. I recently decided to dive into the art of URL rewriting! I thought it was really difficult and would take all sorts of voodoo to get it to do what I wanted, but within a couple of tries I was able to make some pretty advanced URL rewrites.

First of all, if you visit my site from identi.ca (or Twitter), you'll notice my URLs have changed from something like http://cassidyjames.com/blog/?post=57 to http://cassidyjames.com/b/57. This is important especially in micro-blogging because it shaves off ten whole characters. That's over 7% of an entire dent (or tweet)!

I achieve this URL rewriting by modifying the hidden file named .htaccess stored in the root directory of the server. I just had to simply include the line...

RewriteEngine On

...and BAM! the rewrite engine is on (simple enough, right?). Next, I created a rewrite rule on the next line:

RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php

This rule says that my site's URL followed by any character(s) will route to the character(s) plus .php. This means that if I have a file, say "test.php," you can get to it by visiting http://cassidyjames.com/test. This is nice to be able to hide the ".php" from normal users (who don't want to have to type it in) and more advanced users (from whom it obfuscates your server technology).

The next rule I added is actually for the blog specifically. The rule...

RewriteRule ^b/([a-zA-Z0-9_-]+)$ blog/?post=$1

...means that http://cassidyjames.com/b/57 now points to http://cassidyjames.com/blog/?post=57. This allows the blog URLs to be both shorter and prettier.

My final .htaccess rewrite rule I'm going to show isn't actually used on my site, but rather on a church's site I'm helping with. The rule...

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ $1_$2.php

...allows the site admin to use a simple file naming convention to create faux subdirectories. The file "about_ourteam.php" can be created, but the link to it is simply http://stonechurcheagan.com/about/ourteam. This is nice because they don't have to worry about creating directories but they get the advantage of having prettier URLs throughout the site. The only important thing is that all site URLs begin with the root "/" to make sure links and images function properly.

Do you have any fun URL rewriting tips or tricks? Have questions on how to implement this on your site? Let me know in the comments!

Comments for "URL Rewriting Fun"

Setting up my EVO with DMACC Exchange Server Monday, August 23, 2010

It's often touted as a major feature of newer versions of Android, but I never would have guessed that I have a use for synchronizing my EVO with an Exchange server. Today I stand corrected.

My local community college provides each student a webmail account. It uses Outlook Web Access, which, after using for a few days, I found to be a piece of garbage and total waste of time. I set out to figure out how to connect to the Exchange server that runs the mail back-end. After watching a YouTube video of some guy explaining how to do it with Outlook on Windows, I decided I'd find out myself.

I played around with all possible seetings on my EVO and got seriously close to getting it set up; it authenticated and let me add my account, but then errored out when syncing. Finally I gave in and emailed the DMACC support people. They emailed back saying it was possible to use a "Windows Mobile or Linux Droid Smart device" to sync to their Exchange servers using the following settings:

  • Username: DMACC Webmail Username
  • Password: DMACC Webmail Password
  • Account Type: Exchange or Outlook Web Access
  • Mail Server: webmail.dmacc.edu or owa.dmacc.edu
  • Domain: DMACC
  • SSL (required)

I was very tempted to ask what a "Droid Linux Smart device" was, but I resisted and just let them know that I was able to set it up on my "HTC EVO 4G with Android." I also suggested they update their documentation. It turned out all I had wrong was I had ".edu" on the domain.

Hopefully if you have to deal with Outlook Web Access for your organization/school but have an Exchange-compatible device, this post helps you. If you have any tips, feel free to leave them in the comments!

Comments for "Setting up my EVO with DMACC Exchange Server"

New Theme Almost Done Monday, August 23, 2010

I've decided it's finally time to develop a new theme for my site. I thought I'd take some cues from the Ubuntu web guidelines, but I think I've managed to still make it my own.

Most notably, I've decided to use the new Ubuntu font throughout my site. Even if you don't have the Ubuntu font installed, it should show up across my site.

I've also chosen a slightly different color scheme compared to the previous (current) one; the green has been darkened, the background has been changed to a more blue tone, and I've removed the red and blue accents.

Finally, I decided it was time for a true sidebar. On the right side of the site there will be a recent posts section along with some other sidebar-type content.

Check out the in-development theme here and let me know what you think in the comments!

Comments for "New Theme Almost Done"

My new blogging platform. Thursday, August 19, 2010

As a forewarning, this post is half test post for a new identi.ca integration feature and half real post.

I've wanted to begin developing my own little blogging platform for some time now, but never got around to doing it. Well, after a lot of hacking around on my ancient code (seriously, this site was the first code I'd ever written in PHP), I feel like I can actually work toward making a simple and slick blogging platform.

I've decided (for now, at least) to call it cJblog (or cJb for short) for Cassidy James Blog[ging Platform]. It's also ironic because C.J.B. happen to be my initials. I'm not at the point where I can package everything up and let you download/install it on your own server, but that's my next major goal.

Some cool new features, however, have been integrated! As I posted earlier, I've integrated Disqus comments. It makes setting up and managing comments a breeze, so I figured it's a better route than my hacked together custom solution. I may switch back to a custom solution eventually, but this will let me focus on more features.

I have also just integrated a syndicate-to-identi.ca feature. In fact, this is the first post to ever implement it. I still have a lot of work to do, but the skeleton is forming and it's shaping up to be pretty cool.

Comments for "My new blogging platform."

New Disqus-Powered Comments! Thursday, August 19, 2010

No, I'm not coying Engadget with this move (though they did kind of convince me to finally do it), but as of right now, all comments on the site have been switched over to Disqus. I think that works out better in the long run because it lets people post easier and faster than possible with my hackish commenting system.

It's not defeat! I still want to crank my hand-coded blogging system out and add my own features, it just might use Disqus by design since it's such a sweet (and easy) commenting system. Try out the comments below!

Comments for "New Disqus-Powered Comments!"

Displaying 5 most recent posts.

Click here to see all posts.