.htaccess and rewriting in subfolders?

Discuss practical ways rearrange URLs using mod_rewrite.

.htaccess and rewriting in subfolders?

Postby MikeSwede » Mon May 19, 2008 4:21 pm

I have this layout:
http://www.domain.com/search/
In the search folder I have a page, widget_sale.php
this widget_sale.php page can have 2 or 3 parameters, catid, widget and start, so the URL can look like this:
http://www.domain.com/search/widget_sal ... k&start=25. Catid and start will always be numbers but widget can change.
What I want is the URL to look like this:
http://www.domain.com/search/2/clocks.html and if there is a start then I want it to look like this:
http://www.domain.com/search/2/clocks/25.html

I have tried tons of suggestions but I get Page not found :(
MikeSwede
 
Posts: 5
Joined: Sat Jan 27, 2007 8:59 pm

Postby richardk » Thu May 22, 2008 2:06 pm

In a .htaccess file in /
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^search/([0-9]+)/([^/]+)(?:/([0-9]+))?/?$ /search/widget_sale.php?catid=$1&widget=$2&start=$3 [QSA,L]

Or you can remove the first "search/" and put it in /search.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 44 guests

cron