Log in

View Full Version : .htaccess url rewriting



traq
10-02-2009, 03:21 AM
First serious venture into .htaccess...

I'm writing a site that pulls content from a database based on a query string in the url. I want to use .htaccess mod_rewrite to make the urls clean, for example,

www.example.com/home/contact/
will be redirected internally to

www.example.com/index.php?s=home&p=contact
where the script will write the content for the contact page under the home directory.



...I'm getting nothing but 500 errors.

My best guesses are a problem with syntax (I'm not fluent, but I can't find any problems) or an endless loop. I know mod_rewrite is supported by my server, because I have .htaccess files in other directories which use it successfully.

I've tried a lot of variations. I think this is the best I've come up with:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /clients/directory #this .htaccess is currently in a testing directory
RewriteRule ^/([A-Za-z-]+)/*([A-Za-z0-9-]*)/*?$ /page.php?s=$1&p=$2 [NC, L] #match "directory" (letters only) and "page" (IF present, letters and/or numbers)


I'd appreciate any help! thanks, everyone.

techietim
10-02-2009, 07:14 PM
Remove the space in [NC, L].

traq
10-02-2009, 07:38 PM
! thanks
I'll try it out tonight
works perfectly! thanks a lot!

traq
10-17-2009, 01:23 AM
new question... I guess I don't really need a new thread.

I'm trying to turn off magic quotes in php, using this htaccess line (per example at php.net (http://us.php.net/manual/en/security.magicquotes.disabling.php)):
php_flag magic_quotes_gpc Off

I'm getting a 500 error. which, as I learned above, means something's probably wrong with the syntax. I don't have any extra whitespace, and I've experimented with switching the order around to no avail. Any suggestions? Thanks!