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 03-15-2005, 03:24 PM RewriteRule help
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Hi, I've got an .htaccess file which works great, but I need to add one more rule to it, which I haven't been able to do successfully. Here's the existing file:

Code:
RewriteEngine ON

##### Index Page Rules #####
RewriteRule ^(.*)/(.*).php index.php?tid=$1&pid=$2
The existing rule takes

mydomain.com/frontend/$1/$2.php

and points it to

mydomain.com/frontend/index.php?tid=$1&pid=$2

(The .htaccess file is located in the frontend directory.)

This works fine. But sometimes, there is no $pid passed... and this is the situation I need to account for.

In other words, when a user enters

mydomain.com/frontend/$1

I need it to point to

mydomain.com/frontend/index.php?tid=$1

Any help greatly appreciated
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-15-2005, 04:10 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Code:
RewriteEngine ON

##### Index Page Rules #####
RewriteRule ^(.*)           index.php?tid=$1            [S=1]
RewriteRule ^(.*)/(.*).php  index.php?tid=$1&pid=$2
Does that work? If the first rule matches, then the S flag tells the engine to skip the next rule.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
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

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-15-2005, 04:37 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
It doesn't work, but I'm not sure why.... In trying to isolate the problem, all I really found out is that the $_GET['tid'] doesn't get passed. Also, I think possibly an extra slash is being added, in other words it's pointing to

mydomain.com/frontend/index.php/?tid=$1

but I'm not sure yet. I'll run some more tests. Thanks for your help.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-15-2005, 10:18 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Got it working

Code:
##### Index Page Rules #####
RewriteRule ^([^/]+)/$	index.php?tid=$1 [S=1]
RewriteRule ^(.*)/(.*).php  index.php?tid=$1&pid=$2
It takes this:

mydomain.com/frontend/uname/

and points it to this:

mydomain.com/frontend/index.php?tid=uname

Thanks, Chroder, for turning me on to the [S=1], I never would have figured that out myself.

But I do have one more question (for anyone).... is it possible to rewrite the directory name? I like "frontend" because it's more descriptive for me, but "teachers" would be more descriptive for users...

so is it possible to make /frontend/uname/ appear as /teachers/uname/ ?
__________________

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

Last edited by Phaedrus; 03-15-2005 at 10:21 PM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to RewriteRule help
 

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