mod_rewrite regular expressions
This is good to remember when working with .htaccess and mod_rewrite to rewrite your urls in Apache.
Text:
. Any single character
[chars] One of chars
[^chars] None of chars
text1|text2 text1 or text2
Quantifiers:
? 0 or 1 of the preceding text
* 0 or N of the preceding text (N > 0)
+ 1 or N of the preceding text (N > 1)
Grouping:
(text) Grouping of text
Anchors:
^ Start of line anchor
$ End of line anchor
Escaping:
\ char escape that particular char
For more on mod_rewrite, check out this complete guide
Hi, thanks for visiting! I'm John Wright and welcome to my "microblog". This is where I post links and small stuff I find. On occasion, I post on my (regular) blog about web software and cutting (sometimes bleeding) edge technology. I also share links and stuff on Twitter.
PHP code to cache a file forever (well almost)
Sometimes you’d like a file or resource to be cached on the client (or somewhere in between your server and the client) for a long time. Forever would be good. Then if you need to update that resource, you can just rename it or add a ‘version’ query string parameter to force it to be updated after your change.
If you’re serving this file via a PHP then you’ll need to set the HTTP headers. Here’s some code setting the php header to cache forever…
1 2 3 4
| header('Cache-Control: max-age=31556926');
$etag = 'a_unique_version_string';
header('ETag: "'.$etag.'"'); |
Well, actually the first line, sets the php header to cache for a year. The HTTP 1.1 spec recommends a max cache age of 1 year (I think). This is close enough to forever for me.
The next line is recommended also, this is php code to set the “ETag” HTTP header. ETag is basically like a version number for your resource. It should stay cached, on the internet (wherever that is) until you change it. Note: the value of ETag must have double quotes around it.
I like to do something like this …
1
| header('ETag: "'.$_GET["v"].'"'); |
then when I update the file I can change the version in the url like
1
| http://example.com/index.php?v=2 |
That’s it, this is as easy as it gets to using a php header to cache forever.
Bootstrap by Twitter to create a WP Theme
I created the current (as of 12/2011) WordPress theme for my site using Bootstrap from Twitter. This is a great CSS Framework. I’ve actually been wanting something like this for a while. One great thing about Bootstrap is, at minimum there’s just one CSS file to include to use it. This makes it quick and simple to setup and use!
There are more advanced features of it, many look interesting. It appears the entire CSS framework itself was based off of Preboot which is to used in conjuction with Less. I’ll be looking into using Bootstrap with Less as well as the other more advanced JavaScript features.
This all looks very interesting to me, as I’m considering making and releasing my first WordPress theme based on Bootstrap and a few other nice tools I’m aware of. This theme would have a few options which would make it customizable I’m thinking.
Why Occupy Wall Street And Los Angeles?

Since I first read about these protests, I had a feeling this would go somewhere. At the heart of these protests is the message “we are the people. we are losing a lot. we have lost a lot but we still have our voice and we can use it until we are heard”. I think this is mostly about being heard. Yes we want change, yes we need change, but change is easier said than done. The message against corporate greed and corrupt politics is one that I think all Americans can appreciate (99% at least). Read more »
Net Neutrality Discussion And More…
The net neutrality issue is a concern of mine because I really believe that the openness of the Internet in America (and the world) has opened many doors for so many people. I’d hate to see those doors closed.
Even the creator of the World Wide Web Sir Tim Berners Lee is still active in defending the Internet as it currently is and leading the way for the next wave of innovation using web technologies. He highlights some of the freedoms net neutrality has brought in a recent article for Scientific American, Long Live the Web: A Call for Continued Open Standards and Neutrality …
These characteristics can seem obvious, self-maintaining or just unimportant, but they are why the next blockbuster Web site or the new homepage for your kid’s local soccer team will just appear on the Web without any difficulty. Universality is a big demand, for any system.
Decentralization is another important design feature. You do not have to get approval from any central authority to add a page or make a link. All you have to do is use three simple, standard protocols: write a page in the HTML (hypertext markup language) format, name it with the URI naming convention, and serve it up on the Internet using HTTP (hypertext transfer protocol). Decentralization has made widespread innovation possible and will continue to do so in the future.
Recently a guest to my blog started a chat about net neutrality when they visited my Net Neutrality Pros and Cons opinion piece. I wanted to post it here to share it with anyone interested. Here it is…
Guest: Hello, do you have any good information on Bob Kahn on Net Neutrality?
John: I haven’t read this but I’m going to check it out… Father of internet warns against Net Neutrality
Guest: thanks I am currently writing a paper on Net neutrality and am having a hard time giving a strong opinion about it and also talking about net neutrality in other countries
John: I can blab about it real quick to try to give a jist…
basically, the internet has been “neutral” for most of it’s existance and this has opened up opportunities to the little guy with little money to have a much farther reach than ever before…
that’s why these startups can turn into the biggest companies in the world in matter of 10 years or lest (think Google)
on the other hand. The ISPs own many of the actual hardware pipes that all this internet traffic is being transported on…
they have been mostly “neutral” with that traffic.
The idea behind net neutrality legislation is to force them to be neutral as the always have…
(do we really want or need this? it’s not an easy question to answer)
the ISPs could potentially (if not regulated to remain neutral) drastically change the landscape of the internet… even to the point that making so the little guy… doesn’t have the ability and reach to become great in this business playing field now
which is rather scary…
Not that they would change the internet that much, but potentially they could and make a bunch of money for themselves
Read more »
20 Things I Learned About Browsers and the Web
This is really cool. HTML5 at it's best (for the moment) I look forward to the nice interfaces to come.
Facebook’s Mark Zuckerberg Shares Vision For Facebook And More [INTERVIEW]
Some interesting conversation about the future and intersection of mobile/social and Facebook as a platform. Very good listen if you are interested in this space for business and where it’s going.
Mark notes that Zynga market valuation is now bigger than EA is. That is incredible! To think that the social platform that Facebook offers can enable that kind of growth for a startup/company. Amazing.