Welcome to the David Walsh Blog! This website was created to reach every audience possible. Please contact me at david@davidwalsh.name to let me know if I can do anything to further improve your experience on this website.

.htaccess Archives

Create Tiny URLs with TinyURL, MooTools, and PHP

Debuted Wednesday, December 24, 2008 @ 8:58 am
Sugar: .htaccess · AJAX · Blog · MooTools · PHP · XML / XHTML · link()

Since we’ve already figured out how to create TinyURL URLs remotely using PHP, we may as well create a small Ajax-enabled tiny URL creator. Using MooTools to do so is almost too easy.

The XHTML (Form)

<p><strong>URL:</strong> <input type="text" id="url" size="40" /> <input type="button" id="geturl" value="Get URL" /></p>
<p id="newurl"></p>

We need an input box where the user will enter their a URL, a button to trigger the process, and a placeholder to put the new, tiny URL.

Article Sep

Quickly Set Up a Templating System Using .htaccess

Debuted Monday, November 17, 2008 @ 8:47 am
Sugar: .htaccess

Setting up a website capable of easy template switching probably sounds difficult. When I first thought about building a templating system, it felt like a pretty daunting task. After tinkering around for a few days, I found a way that would allow me to switch templates by simply changing a .htaccess directive.

The Folder Structure

+ root
	+ templates
		+ version1
			- css
			- graphics
			- js
		+ version2
			- css
			- graphics
			- js
		+ version3
			- css
			- graphics
			- js

Note that the different templates go in different folders within the temlpates folder — that includes template graphics, CSS styles, and javascript files. If any other types of files are specific to your template, you may add a directive to make them template-specific as well.

Article Sep

Check For Module Presence in .htaccess

Debuted Friday, November 7, 2008 @ 8:44 am
Sugar: .htaccess

One of my favorite Apache modules is mod_rewrite. mod_rewrite allows me to manipulate page URLs so that I can search engine friendly URLs. Not every Apache server has the mod_rewrite module installed so you will want to add a conditional statement within your .htaccess file to make sure it’s there.

The .htaccess

#Wordpress's .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

If the “mod_rewrite.c” module is present, that means that mod_rewrite is available and will be used. If not, the mod_rewrite code will be ignored. Using this conditional statement will prevent 500 Internal Server Errors.





 

 

comments twitter