TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-23-2008, 02:17 AM   #1 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default Mod Rewrite only partially working

Hello,

I need some help!

I've managed to get part of the mod rewrite working, it works with only one variable, but in fact i need 2!

This is what i have so far:

Code:
RewriteEngine on


RewriteRule ^watch/([^/\.]+)/?$ video.php?season=$1 [L]
RewriteRule ^watch/([^/\.]+)/([^/\.]+)/?$ /video.php?season=$1&episode=$2 [L]
I basically want URL/watch/seriesNumber/episodeNumber to become available to video.php with variables $_GET['season'] and $_GET['episode'].

It works if you only put the series in to the url, but says that the object isnt found if i put the episode number in..

Any help?

Ta Gareth
Gareth is offline  
Reply With Quote
Old 12-23-2008, 02:32 AM   #2 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

Got it working, it needed the /\ to be deleted... how weird!mail

Last edited by Gareth : 08-31-2010 at 10:59 AM.
Gareth is offline  
Reply With Quote
Old 12-23-2008, 02:38 AM   #3 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

Nope that wasnt a fix!
Gareth is offline  
Reply With Quote
Old 12-23-2008, 03:00 AM   #4 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I'm not 100% sure but try this:

Code:
RewriteEngine on

RewriteRule ^watch/([0-9]+)$ video.php?season=$1 [L]
RewriteRule ^watch/([0-9]+)\/([0-9]+)$ video.php?season=$1&episode=$2 [L]
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 12-23-2008, 12:01 PM   #5 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

Wouldnt that just look for numbers? actually i didnt explain myself very well, the season number contains a letter, like: season-1...
Gareth is offline  
Reply With Quote
Old 12-23-2008, 03:49 PM   #6 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Try this:

Code:
RewriteEngine on

RewriteRule ^watch/([^/]*)$ video.php?season=$1 [L]
RewriteRule ^watch/([^/]*)\/([^/]*)$ video.php?season=$1&episode=$2 [L]
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 12-24-2008, 06:08 PM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

The problem is not with the regex specifically, but with the lines order. #2 should be first, and #1 should be second. Assume you want to test this string: watch/seriesNumber/episodeNumber. Rule #1 is hit, because watch/ is present in the beginning of the string, and that's about all that rule assumes. Being the [L](ast rule to process), once the condition is met, the .htaccess file is never processed. Now, your rules are also broken.

Code:
[^/\.]
That pattern will match "everything that is not a character nor a forward slash". That sounds pretty ambigous, don't you think? You'd better go for:

Code:
^watch\/([^\/]+)\/([^\/]+)\/?$
-- #2
, respectively:
Code:
^watch\/([^\/]+)\/?$
-- #1
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mod Rewrite Made Easy CMellor Libraries & Extensions 12 12-14-2008 02:13 PM
Good 'ol mod rewrite help needed... h0ly lag XHTML, HTML, CSS 3 11-01-2008 05:52 AM
Exec(zip) in PHP not working as expected oscargodson General 3 09-28-2008 12:00 PM
How to do ISAPI rewrite in zend framework (IIS) ? yusufeen Advanced PHP Programming 0 07-16-2008 12:26 PM
mod rewrite - how to get title in url? Sam Granger Absolute Beginners 5 10-10-2007 02:58 PM


All times are GMT. The time now is 01:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design