SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy htaccess URL rewriting method

    I need to rewrite my site url for seo reason. For example current "about" page url of my site is http://localhost/beautiful/?option=c...=1&itemId=1.sf
    I want to rewrite it as http://localhost/beautiful/content/about
    I have tried it with the following htaccess rule

    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^beautiful/(.*)/(.*)/(.*)$ beautiful/index.php?option=$1&cat_id=$2&itemId=$3 [L]

    but it's not working. can anyone help me please?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    arif,

    Your regex requires three atoms separated by /'s following beautiful/ - your beautiful/content/about only has two so NO MATCH.

    If you need more information about mod_rewrite (believe me, using (.*), you DO), please refer to the tutorial Article linked in my signature.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi David
    thanks for your reply. but still i can't figure it out.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    ari,

    If you're familiar with regular expressions, it's trivial. If you're not, mod_rewrite is not the tool for you.

    For instance, your URI is beautiful/?option=content&cat_id=1&itemId=1.sf and you want to rewrite beautiful/content/about to that URI.

    Therefore, you need to capture content and ... duh ... about is not a value in the query string.

    Normally, you'd have beautiful/value1/value2/value3 and redirect that to beautiful/index.php?option=value1&cat_id=value2&itemId=value3. You only have two values so, unless one of your values is fixed, you just can't do this.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you change all those rewrite mod modules at httpd.conf? If you had already done so, perhaps it should work fine. Or you can post your sample URL for us to know better.
    ~Hard works bear fruits.


Tags for this Thread

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
  •