Need help changing URLs with .htaccess

Discussion in 'Programming' started by Riboflavin, Jun 27, 2009.

  1. #1
    Hi there,

    on my site, I want users to be able to go to mysite.com/search/var1/var2/var3/ and have the server display search.php?stype=var1&keywords=var2&page=var3

    Here is my .htaccess as I have it now, it seems right to me but I must be missing something because when I try and go to the shortened URL I just get a 404. Any help would really be appreciated :thumbsup:

    #this makes my server run as php5
    AddHandler php5-script .php
    
    RewriteEngine On
    
    #These two lines remove www from the URL
    RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    #This is what I need help with
    RewriteCond %{REQUEST_URI} ^search/(.+)/(.+)/(.+)/$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/search.php?stype=$1&keywords=$2&page=$3/ [R=301,L]
    Code (markup):
     
    Riboflavin, Jun 27, 2009 IP
  2. Riboflavin

    Riboflavin Well-Known Member

    Messages:
    1,091
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    155
    #2
    I solved my problem using this instead of the last two lines

    RewriteRule ^search/(.*)/(.*)/(.*)/ search2.php?stype=$1&keywords=$2&page=$3
    Code (markup):
     
    Riboflavin, Jun 27, 2009 IP