Quick RewriteRule help needed

Discussion in 'Apache' started by mr_bill, Jul 11, 2007.

  1. #1
    I have a url that reads
    index.php?dir=10-webtraffic/
    would like it to be
    category/10-webtraffic/

    Then I have links like this
    downloads/10-webtraffic/Effectively-Using-Overture-Yahoo-To-Get-Website-Visitors.txt
    I would like to replace the "-" with "_"
    Does this last part work better for search engine friendly urls


    Thank you in advance :)
     
    mr_bill, Jul 11, 2007 IP
  2. pruad

    pruad Peon

    Messages:
    71
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1) try something like that:

    RewriteRule ^index.php?dir=([a-z0-9\-]+)/?$ /category/$1/ [NC,L]
     
    pruad, Jul 11, 2007 IP
  3. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Thanks for the try is didnt do anything. I have also decided not to change the hyphens to underscores. Just looking to change the index.php?dir= to category
     
    mr_bill, Jul 11, 2007 IP
  4. personalpa

    personalpa Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    RewriteRule ^category/(.*)$ index.php?dir=$1
    
    Code (markup):
     
    personalpa, Jul 11, 2007 IP
  5. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #5
    knew it wasnt just me that one didnt work either :(

    This is being applied to the 3rd link in my signature didnt work
     
    mr_bill, Jul 11, 2007 IP
  6. personalpa

    personalpa Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    RewriteEngine on 
    RewriteRule ^category/(.*)$ index.php?dir=$1
    
    Code (markup):
    In which folder are you saving this?
     
    personalpa, Jul 11, 2007 IP
  7. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #7
    its being put in the public_html


    I will hire someone to sort this out. I think I have some php code that is conflicting or changing it.
     
    mr_bill, Jul 11, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^category/([^.]+)/$ index.php?dir=$1 [L]


    - are better than _ SEO wise.
     
    Nintendo, Jul 11, 2007 IP
  9. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #9
    Nintendo thank you for your try. I am looking for someone to look in to the code as it Htaccess.php which I think is keeping the rewrites from working. I could be wrong.

    Thank you also for the "_" "-" answer found out that the "_" actually is ignored by the engines basically removing them and combining the words. where as the "-" is recognized as stop so the engine sees all the words as keywords.
     
    mr_bill, Jul 11, 2007 IP
  10. Dark Rider

    Dark Rider Guest

    Best Answers:
    0
    #10
    your files name should be .htaccess no htaccess.php or as far as i know that is how it should be, it's that way on my sites. I am not on my normal pc that I use for my websites do I dont have any of my files but tomorrow morning if you havnt figured this out I can send you a file to use. (i don't remember the code off the top of my head)
     
    Dark Rider, Jul 11, 2007 IP
  11. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #11
    I know but in this file it is rewriting things I will supply a snippet of it to show this.

    So this file is making the htaccess rewrites not work
     
    mr_bill, Jul 11, 2007 IP