mod_rewrite

Discussion in 'Apache' started by mark_s, Jul 27, 2006.

  1. #1
    mark_s, Jul 27, 2006 IP
  2. Voasi

    Voasi Active Member

    Messages:
    1,054
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Yes. Their is a mod_rewrite forum on here...or maybe its Apache. Either way, go to that forum and post it there. They'll be able to help.

    Also, doing a couple of quick searches in Google and you'll find what you're looking for. Search under: .htaccess mod rewrite
     
    Voasi, Jul 27, 2006 IP
  3. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #3
    This is easy.

    1. Look for .htaccess in your root directory. If it is not there, create it.
    2. Look for:
    RewriteEngine ON
    in the beginning. If it is not there, type it as the first line.
    3. Type:
    RewriteRule ^page-(.*)$ index.php?page=$1 [L]
    4. Try this:
    www.mysite.com/page-contact

    If it works fine, you will need to change all links on the site to /page-(page_here)
     
    Lordo, Jul 27, 2006 IP
  4. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is there anyway to have that without the "page-" and also would a trailing slash still work?
     
    mark_s, Jul 27, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    (First two lines might not be needed.)

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/$ index.php?page=$1 [L]

    This is if the index file is index.php and make sure you have no real directories, or they'll be messed up, hince the page- suggestion he gave you!

    er...after you try it, go to domain.com/messageboard/ and you'll see why you need the page- part. You need something unique in the URL. .html would work.
     
    Nintendo, Jul 27, 2006 IP
  6. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I do have real directories so I guess doing what I really want (no manual adding to htaccess per page) isn't possible.

    I'll have to stick with this:

    RewriteEngine on
    RewriteRule ^(profile|biography|schedule|quotes|career|results|images)(/)?$ /?page=$1

    Thanks everyone anyway....
     
    mark_s, Jul 27, 2006 IP