Results 1 to 4 of 4

Thread: .htaccess url rewriting

  1. #1
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default .htaccess url rewriting

    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,
    Code:
    www.example.com/home/contact/
    will be redirected internally to
    Code:
    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:
    Code:
    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.

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    Remove the space in [NC, L].

  3. The Following User Says Thank You to techietim For This Useful Post:

    traq (10-02-2009)

  4. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    ! thanks
    I'll try it out tonight
    Edit: works perfectly! thanks a lot!
    Last edited by traq; 10-03-2009 at 02:34 AM.

  5. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    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):
    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!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •