NYCPHP Meetup

NYPHP.org

[nycphp-talk] not including '.php' in URI

Kenneth Dombrowski kenneth at ylayali.net
Wed Mar 22 14:32:15 EST 2006


for Ajai & Adler, 

mod_rewrite is another way.  here's more of my example from yesterday
(from an .htaccess file) 

note RewriteLog cannot be set from .htaccess files, so you might have to
develop your rules locally, on a server you control, and only upload
them to your hosted account after they work. 

# ======================================================================
# RewriteRules to support old-style and friendly URLs
# ======================================================================
# *** For debugging set RewriteLog in httpd.conf *** 
#
RewriteEngine On
#
#                    F I N A L   R E Q U E S T S
#
# these are requests for the actual files on disk; stop processing.
#
RewriteRule ^catalog.php$               - [NC,L]
RewriteRule ^account.php$               - [NC,L]
RewriteRule ^index.php                  - [NC,L]
RewriteRule ^search.php                 - [NC,L]
#
#                          O L D   U R L S
#
# add support for URLs from old version of site, to avoid breaking
# bookmarks/links/caches.  The redirects will indicate to the user that
# the correct URL has changed (due to [R])
#
# index.php is no longer the artist search page
RewriteRule ^index.php?selection=ARTS   catalog/artists [NC,R,L]
RewriteRule ^index.php?selection=(.*)   catalog/artists/$1 [NC,R,L]
# former by-name searches
RewriteRule ^index.php?whomlab=(.*)     catalog/label/$1 [NC,R,L]
RewriteRule ^index.php?whomart=(.*)     catalog/artist/$1 [NC,R,L]
#
#                      F R I E N D L Y   U R L S
#
# (note we are intentionally not using the [R] flag here)
# 
RewriteRule ^account$                   account.php [NC,L]
RewriteRule ^account/edit$              account.php?action=edit [NC,L]
RewriteRule ^catalog/recent$            catalog.php?filter=recent [NC,L]
RewriteRule ^catalog/artists$           catalog.php?list=artists [NC,L]
# catalog/artist/dead+c -> catalog.php?filter=artist&name=dead+c
RewriteRule ^catalog/artist/(.*)$       catalog.php?filter=artist&name=$1 [NC,L]
RewriteRule ^search$                    search.php [NC,L]
#
# support a few common mistakes (_do_ use the [R] flag here): 
# 
RewriteRule ^catalog/search$            search.php [NC,L,R]





More information about the talk mailing list