Skip to main content

Apache Re-write Explained

Apache Re-write Explained

I don’t pretend to be an ‘Apache Expert’, in fact I don’t pretend to be an expert in anything…. But a little knowledge is very handy…

Here’s a great article that I found helpful on several occasions.

http://corz.org/serv/tricks/htaccess2.php

Handy examples are:

# users can load only "special.zip", and the css and js files.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^(.+)\.css$
RewriteCond %{REQUEST_FILENAME} !^(.+)\.js$
RewriteCond %{REQUEST_FILENAME} !special.zip$
RewriteRule ^(.+)$ /chat/ [NC]

Here we take the whole thing a stage further. Users can access .css (stylesheet) and Javascript files without problem, and also the file called “special.zip”, but requests for any other file types are immediately redirected back up to the main “/chat/” directory. You can add as many types as you need. You could also bundle the filetypes into one line using | (or) syntax, though individual lines are perhaps clearer.

I often use:

# Send all pages with /vote/ in the URL to the vote.php page for processing
RewriteRule ^vote/(.*)$ /vote.php?req=$1 [L,QSA]
Main Category
  • HTML and CSS
  •  
 
Jon Moore

Search form

Jon Moore

Tips 'n' Snips

 
  • Home
  • General
  • Drupal
    • Drupal 6
    • Drupal 7
    • Module Building
  • HTML & CSS
  • Javascript
  • jQuery
  • PHP
    • CodeIgniter
    • Handy Functions
    • MySQL
  • WordPress
  • About

BBC Technology News

  • Heathrow: Man charged with flying drone near airport
  • Girl Scouts of America offer badge in cybersecurity
  • Rise in nude photos sent to phones on public transport
  • Are these the faces of the future?
  • Zimbabwe blocks Facebook, WhatsApp and Twitter amid crackdown
More

Sitepoint

  • How to Build Your First Static Site with Gatsby
  • Customer Journey Maps: A Day in the Life of a Customer
  • How to Take JavaScript Beyond the Web in 2019
  • Check out the 6 Best Productivity Apps for Designers
  • 7 Awesome Wireframing Tools You Should Be Using
More

Heart Internet

  • Did he really just say that? How to deal with an obnoxious client
  • Product management for designers
  • Talking to your clients about WordPress plugin security
  • The developer’s guide to native web animation
  • Are you seeing clearly? The role of visual thinking in creative work
More
 

Backend Coders

  • PHP
  • Handy PHP Functions
  • PHP MySQL

Frontend Coders

  • HTML & CSS
  • jQuery
  • Javascript

CMS/CMF Systems

  • Drupal
  • Drupal 6 Specific
  • Drupal 7 Specific
  • Drupal Module Building
  • WordPress

About

  • Home
  • About
 

© Jon Moore 2019

All stock images are from www.istockphoto.com