egypturnash: (Default)
[personal profile] egypturnash
I got someone complaining that the menus on my site didn't load one too many times. They're generated by a little bit of Javascript, which tends to die on IE because people just turn off any and all scripting 'cause it's so full of security holes.

So I've converted it all to use a bit of PHP that generates the menu on the server end. This causes the problem that all my URLs will change, because I have to have everything be filename.php for this to work... or does it?

Not after a little fooling around with mod_rewrite, it doesn't! I shoved this in my .htaccess, above the code that prettifies the URLs to my gallery:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} ^(.*)\.html$
RewriteCond %1.php -f
RewriteRule ^(.*)\.html$ $1.php [ne,nc,l]


Translated into English, this tells the web server to do this:

If the user asks for a file whose name ends in .html, and if there's a .php file with the same name, give them the .php file instead. And stop doing the rewriting thing.

Yeah, I know, I could just stick the damn menu code in every file, but that means changing and re-uploading every file on my website when I change what's in the menu. It's a lot easier this way. Really. At least it is when you're a geek like me whose teeth grind at the thought of doing something by hand several times!

Date: 2006-08-04 09:47 pm (UTC)
ext_646: (Default)
From: [identity profile] shatterstripes.livejournal.com
Yay for Textmate. It's the first text editor I ever decided to shell out cash for!

I dunno if I could get by with something quite that simple and ubiquitous; I have some basic design rules but each page of my site has a lot of unique layout going on. Going to a minimal CMSoid thing might be slated for the next redesign, which is probably coming in, oh, 2011 or so, if I keep this one as long as I kept my old site. (Which generates the headers with a little cgi-bin I wrote in C.)

Profile

egypturnash: (Default)
Margaret Trauth

October 2020

S M T W T F S
    123
45678 910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Expand Cut Tags

No cut tags
Page generated Jul. 2nd, 2025 04:39 am