[SWLUG] URL rewrite help

Hugh Morris hugh at salsacardiff.com
Mon Jan 10 15:05:43 UTC 2005


Steve is right, that's the best was to set up a new site but it can be a 
lot of work to change an existing site. In your situation, if you want 
to change just a few pages you can redirect each one in .htaccess like this:

(first, turn on url rewriting)
RewriteEngine on

(then give each new file its own line like this)
RewriteRule ^mydirectory/myfile\.html$ 
http://www.mysite.com/mydirectory/myfile.php [R=301,L]
(all on one line)

If you want to change many files here and there on your site, the 
easiest way to take care of this is to save your new php files with the 
extention html and set apache to check all files for php. You do this by 
adding a MIME type declaration to the top of your .htaccess, like this:

# causes html to be parsed as php
AddType application/x-httpd-php .php .html



More information about the Swlug mailing list