SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Rewrite trouble

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rewrite trouble

    I am having some rewrite trouble of an odd URL structure on my page. I'm trying to get some "seo" friendly links for an inventory section. Here is the type of link I am looking to transform:

    blahh.com/detail/?numb=9795&yr=2012&make=NEWMAR&model=KING%20AIRE%204584

    Basically I would like to rewrite it as

    blahh.com/detail/9795/2012/NEWMAR/KING AIRE 4584 .. you get the picture

    Here is my .htaccess command which is not currently working. I'm sure I am doing something wrong here..

    Code:
    Options +FollowSymLinks
    RewriteRule ^detail/([0-9]+)/([0-9]+)/([a-zA-Z]+)/([a-zA-Z]+)/$ detail/?numb=$1&yr=$2&make=$3&model=$4
    By the way, this is through Wordpress. Any help would be much appreciated!

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

    I can see two things:

    1. You've not shown your test URI which I believe does not have a trailing /

    2. Your fourth atom does not accommodate the use of spaces in the model name (nor digits)

    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, tYou might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    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 Enthusiast
    Join Date
    May 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've read through your notes, but it still seems messed up. I even used a dot operator as the last regex match to capture everything. Here is my whole .htaccess (with Wordpress stuff included)

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    #Begin SEO Friendly URLs
    Options +FollowSymLinks
    
    RewriteRule ^detail/([0-9]+)/([0-9]+)/([a-zA-Z]+)/([.]+)/$ detail/?numb=$1&yr=$2&make=$3&model=$4

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

    Move your RewriteRule before the WP code (and REMOVE THE <IfModule> WRAPPER!)

    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


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
  •