PDA

View Full Version : Need help changing URLs with .htaccess


Riboflavin
06-27-2009, 02:30 AM
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]

Riboflavin
06-28-2009, 02:56 AM
I solved my problem using this instead of the last two lines

RewriteRule ^search/(.*)/(.*)/(.*)/ search2.php?stype=$1&keywords=$2&page=$3