Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess: URL Rewriting

Status
Not open for further replies.

xml2

Programmer
Joined
Jul 18, 2003
Messages
20
Location
BE
Hi everybody, I'm starting to get frustrated here.. I'm trying to get to know 'mod_rewrite' a little better, so I wanted to make a little excercise...

What I want is the following ('product1' is the variable)

==>> product.php?name=product1

I got this part working, but only with numbers, to get:

==>> product.php?naam=12

I use the following Rule:

RewriteRule ([0-9]+) product.php?name=$1

and that works fine. The moment I'm trying to make it work with characters I get errors.. somebody willing to help me a little? I cannot explain how long I've been looking for this.. :/ (I want that every charachter after de '/' should be put behind 'name=')

I hope my problem is a little 'clear', sorry for the realy bad english. (but at least I trying, right?)
 
Try
Code:
RewriteRule (.+) product.php?name=$1

//Daniel
 
Hi Daniel,

Thx for trying to help me, but when I do that, I don't get the string that I put behind the / but I just get 'product.php' as value frome 'name'.

You have any ID?
 
I'd use

RewriteRule ^/(.*?)$ /product.php?name=$1

If you have any other specifics on the regex to match you can slide them in easily. Like a path

RewriteRule ^/store/(.*?)$ /product.php?name=$1

etc etc




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top