Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
mod_rewrite ... need to get query values and forward to /page/query_value/
Old 10-01-2004, 10:58 PM mod_rewrite ... need to get query values and forward to /page/query_value/
kisk's Avatar
Extreme Talker

Posts: 161
Location: skynet
Trades: 0
Hi. Ok, here's the setup: I'm using php and trying to use mod_rewrite to make all my pages SE friendly.

My old pages were in the format:
site.com/customize.php?shirt=BLAH

The way I have it setup now I have my links going here:
site.com/t-shirts/BLAH/

This is the rule I used and it works fine::
RewriteRule ^t-shirts/([a-zA-Z0-9_-]+)(/*)?(.*)?$ /customize.php?shirt=$1 [L]


The problem is I have incoming links pointed at my customize.php page so I'd like to do a 301 redirect (permanent) from the customize.php page to the new page which uses the rewrite (/t-shirts/BLAH/).

I'm pretty sure I need to use a RewriteCond to pull the query value and pass it but I'm not sure how to do it. My attempt was like this:
RewriteCond %{QUERY_STRING} shirt=([^&;]*)
RewriteRule ^customize.php$ /t-shirts/%1/ [R=301,L]

... but it always leads me to /t-shirts/THE_COMPLETE_QUERY

With:
RewriteRule ^customize.php$ /t-shirts/%1/ [R=301,L]

.. how do I make %1 just be the VALUE of 'shirt='?


Thanks!
kisk is offline
Reply With Quote
View Public Profile Visit kisk's homepage!
 
 
Register now for full access!
Old 10-05-2004, 12:45 PM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Check out this page for a good guide to mod rewrite. http://httpd.apache.org/docs/misc/rewriteguide.html

I personally dont faff about coding like that, instead each seperate extension (customise.php) gets a folder of its own and an index.php inside their.

Then you just browse to http://your-site.com/customise/?param=value

But if your sites not built like that then its a complete pain in the back side attempting to get it like that.

Mod-rewrite is your best option though i couldnt possibly help you with tinkering with it myself.

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to mod_rewrite ... need to get query values and forward to /page/query_value/
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 5.89845 seconds with 12 queries