+ Reply to Thread
Results 1 to 4 of 4

Thread: Using mod_rewrite to optimize URLs

  1. #1
    omniuni's Avatar
    omniuni is offline Jewbergeek!
    Join Date
    Jul 2007
    Posts
    181
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using mod_rewrite to optimize URLs

    Hi,

    I have some websites running at http://jerrysartaramastores.com/ and would like to use mod_rewrite to simplify the URLs.

    I set up a demo site to play with.

    Right now, for example, I would use:
    http://demo09.jerrysartaramastores.com/?page=contact
    and I want to use:
    http://demo09.jerrysartaramastores.com/contact

    I created a .htaccess, and gave it the following content:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/([^/\.]+)/?$ index.php?page=$1 [L]
    I simply get a 404.

    Any idea what I'm doing wrong?

    Thanks in advance.
    [URL="http://d-site.net"]http://d-site.net/[/URL]

  2. #2
    Colin's Avatar
    Colin is offline Wait, What?
    Join Date
    Aug 2007
    Posts
    175
    WHB Points this Month
    0.00
    WHB Points
    5.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Following is based on mambo's rewrite rule for making SEO url's:
    [code]
    RewriteEngine On

    # Uncomment following line if your webserver's URL
    # is not directly related to physical file paths.
    # Update YourMamboDirectory (just / for root)

    # RewriteBase /YourMamboDirectory

    #
    # Rules
    #

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^content/(.*) index3.php
    RewriteRule ^component/(.*) index3.php
    RewriteRule ^mos/(.*) index3.php
    [/code]

  3. #3
    omniuni's Avatar
    omniuni is offline Jewbergeek!
    Join Date
    Jul 2007
    Posts
    181
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Um, thanks, but I don't think that really helps me much. All I want to do is grab whatever is after the "/", like "xyz" and append it to "?page=" so that "?page=xyz".
    [URL="http://d-site.net"]http://d-site.net/[/URL]

  4. #4
    omniuni's Avatar
    omniuni is offline Jewbergeek!
    Join Date
    Jul 2007
    Posts
    181
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fixed

    WHB is awesome.

    As per their help:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/([^/\.]+)/?$ index.php?page=$1 [L]
    [URL="http://d-site.net"]http://d-site.net/[/URL]

+ Reply to Thread

Posting Permissions

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