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.
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.