redirect one folder only

New to mod_rewrite? This is a good place to start.

redirect one folder only

Postby jon23d » Mon Apr 26, 2010 10:05 am

I used to do all sorts of things with modrewrite, but discovered I hated it and finally decided to parse everything with PHP. This hasn't been a problem until I deployed a site that streams video to a shared host and found that the php processes were running throughout the entire stream.

Here is what I started with:

Code: Select all
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On

php_flag magic_quotes_gpc Off
php_flag register_globals 0

RewriteRule ^(.*)$ dispatcher.php [NS,QSA,L,NC]


A request for a valid video would look like this: http://myhost.com/videos/myvideo.swf, but the file is actually located at resources/videos/myvideo.swf. I would like for those videos to be handled by apache, and let php handle everything else.

I've tried all sorts of variations of things like this before the dispatcher call, but nothing seems to work...

Code: Select all
RewriteCond $1 !^videos/(.*)$
RewriteRule ^videos/(.*)$ resources/videos/$1 [NS,QSA,L,NC]
jon23d
 
Posts: 19
Joined: Sun Feb 01, 2009 11:36 pm

Re: redirect one folder only

Postby jon23d » Mon Apr 26, 2010 11:31 am

I've tried to make it so that all calls are sent to dispatcher, unless they are in the videos folder, but it appears as if the call is being sent back for processing again...

Code: Select all
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On

# disable magic quotes
php_flag magic_quotes_gpc Off

# disable register globals
php_flag register_globals 0


# redirect everything that is not in the resources/videos folder to the dispatcher
RewriteCond %{REQUEST_FILENAME} !(.*)/videos(.*)
RewriteRule ^(.*)$ dispatcher.php [QSA,L]

#Everything else goes to dispatcher2
RewriteRule ^(.*)$ dipatcher2.php?x=$1 [QSA,L]


dispathcer.php is showing me the querystring with x instead of dispatcher2.php showing it...
jon23d
 
Posts: 19
Joined: Sun Feb 01, 2009 11:36 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 16 guests

cron