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!
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

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. 4th, 2025 04:12 am