apache & rewrite

Oct 27, 02:14 PM

http://www.addedbytes.com/cheat-sheets/

example .htaccess:

RewriteEngine On

## let index.php go thru as is, but dont let any other rules apply

RewriteRule ^webpages/.*$ – [PT]
RewriteRule index.php index.php [L]
RewriteRule ^/?([\w\-]+)\.(html|php)$ index.php?page=$1.$2 [L]

^ – beginning of string
[\w\-] – any word character A-Za-z0-9_ or a dash
+ – one or more of these characters
(html|php) – followed with html or php
$ – end of string
() – capture into strings $0 $1 $2 etc

debugging: put this into the /etc/http/conf/httpd.conf file:

RewriteLog /etc/httpd/logs/rewrite_log
RewriteLogLevel 3

NameVirtualHost *:80

then do: apachectl restart

note: to SKIP a subdirectory:
RewriteRule ^Foo/.*$ – [PT]
this was found here

==========================2008-11-26
addition: to make a directory ‘browser-directory’ friendly, add this line to .htaccess:

Options +Indexes

Mark Edwards

,

---

Commenting is closed for this article.

---