1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mod_rewrite + .htaccess Problem

Discussion in 'Apache' started by Fl1p, Nov 20, 2007.

  1. #1
    I currently have this on my .htaccess file
    So that will produce www.domain.com/url.html

    Now I want to add this...
    So that will produce www.domain.com/buy/something

    BUT when I combine everything in one .htaccess file I'm getting an infinite loop on my website...

    Any idea how to fix this? Any help will be greatly appreciated.

    Thanks
     
    Fl1p, Nov 20, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    I don't see what is causing the infinite loop, but try this:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule (.+)\.html$ index.php?page=$1 [L]
    RewriteRule ^buy/([^/]+)/?$ index.php?page=buy&catname=$1 [L]

    Also, why are using .html extensions, why not just get rid of it altogether? e.g. domain.com/buy, domain.com/buy/item

    Which would be:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^buy/([^/]+)/?$ index.php?page=buy&catname=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ index.php?page=$1 [L]
     
    krt, Nov 20, 2007 IP
    Fl1p likes this.
  3. Fl1p

    Fl1p Active Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks for the reply.

    I got help from another forum and fixed it using the code below...

    As for your question, there's really no specific reason why I'm using .html extension, its just I started using .html extension on my old pages and I don't really want to replace those with the new URL format...

    Thanks again!
     
    Fl1p, Nov 20, 2007 IP