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.

PHP Forum


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



Freelance Jobs

Reply
Old 02-15-2007, 12:59 AM Mod Rewrites
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Hi all,
I have a question about using rewrites in php/apache.
One thing i cannot seem to figure out is this.

I have for example a feedback page. This page is accessed through a list of users so you can provide feedback for a user. The link needs to pass the ID of the user so the page knows which user you are commenting on. The link is like this:

Code:
 <a href="feedback/44243/">user</a>
And the rewrite rule is like this:

Code:
 RewriteRule ^feedback/([0-9]+)(/)?$ index.php?dir=users&file=feedback&userid=$1
As you can see my rule is requires you to pass an ID. Fair enuf.

However, this page has a form which submits to itself so it can process the feedback and display a un/successful message. Therefore, if the form submits to itself, i don't need to pass the ID through the querystring anymore since i can use hidden form variables, so, i want to the action of the form to be:

Code:
 action="feedback/"
The problem is that from the above rule, i have set the rule to require variables. If i define another rule for feedback without the variables, it won't find the page. Therefore im forced to set the action to include the userid again - which i'd prefer not to.

What am i doing wrong or is there better way i should be doing this?

Thanks in advance.
vn5ltr is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-15-2007, 02:16 AM Re: Mod Rewrites
Extreme Talker

Posts: 217
Trades: 0
Just a wild guess but...

RewriteRule ^feedback/$ index.php?dir=users&file=feedback
I think that would work, unless the file has to have the user ID variable defined.

If that doesnt work, perhaps you may want to post the contents of the PHP script, that might be of more help.
__________________

Please login or register to view this content. Registration is FREE
Slick Nick is offline
Reply With Quote
View Public Profile
 
Old 02-15-2007, 06:22 PM Re: Mod Rewrites
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Nope no go.
I know theres gota be some way, my wild guess is to use Rewrite conditions, although i've never tried it before.
Any help?
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 02-17-2007, 03:08 AM Re: Mod Rewrites
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
RewriteRule ^feedback\/?$ index.php?dir=users&file=feedback [L]
# I am not quite sure about trailing slash, you must look into your rewrite log
# the [L] directive tells apache to stop rewriting after performing this rewrite
RewriteRule ^feedback\/([0-9]+)?\/?$ index.php?dir=users&file=feedback&userid=$1 [L]
# this one will pass empty userid if the previous rewrite is not performed
__________________

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

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-18-2007, 02:55 AM Re: Mod Rewrites
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
mtishetsky,
thanks, i will try that when i'm back at work tomorrow and post the results.
Cheers
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 02-18-2007, 09:07 PM Re: Mod Rewrites
vn5ltr's Avatar
Skilled Talker

Posts: 93
Location: Melbourne, Australia
Trades: 0
Works fine mtishetsky. It was actually my problem in the php code itself that was causing the mishaps, and applying the [L] attribute is useful.

Thank you for your help.
Cheers.
vn5ltr is offline
Reply With Quote
View Public Profile
 
Old 02-19-2007, 01:51 AM Re: Mod Rewrites
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Give me my talkupation!
__________________

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

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Mod Rewrites
 

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 0.37692 seconds with 12 queries