Gossamer Forum
Home : Products : Gossamer Links : Discussions :

mod_rewrite and PHP

Quote Reply
mod_rewrite and PHP
Hi

Recently I've changed my static directory to dynamic with mod_rewrite rules. I've put something like this in my .htaccess file
Code:
RewriteEngine On
RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^AddImages/(.*) AddImages/$1 [L]
RewriteRule ^Images/(.*) Images/$1 [L]
RewriteRule ^p/(.*) /cgi-bin/page.cgi?g=$1 [L]
RewriteRule ^info/(.*) /cgi-bin/page.cgi?p=$1 [L]
RewriteRule ^(.*).shtml /cgi-bin/page.cgi?g=$1.shtml [L]
RewriteRule ^$ /cgi-bin/page.cgi [L]

My question is, can I use .php extension with pages but still run it as dynamic? Will there be any problem with this?
I want to change this line in my .htaccess file:
Code:
RewriteRule ^(.*).php /cgi-bin/page.cgi?g=$1.php [L]

Regards.

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
Anyone? Unsure

Regards

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
You can't use mod_rewrite with the .php extensions, as its not being run through PHP (its going through page.cgi, which can't run PHP commands directly).

Any reason why you would want/need to use .php extensions?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
Yes. Want to include some own PHP code in it...

Regards.

UnReal Network
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
I guess this won't work, right?

Regards.

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
What kind of PHP code are you trying to include? You could use a global to run the PHP script ... but it depends on what you are trying to do with the PHP (i.e time/date/include/etc).

If you are only trying to include something ... then let me know, as I'm 100% sure there is a global floating around, which does this.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
Well, what I want is to include php code for running one external PHP script (banner management).

Regards.

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
Is this post any help?

http://www.gossamer-threads.com/...i?post=274494#274494

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
Hi,

Don't sure know is that helping. For example, this is code for inserting banners in phpadsnew script:
Code:
<?php
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:3', 0, '_blank', 'front', '1', $phpAds_context);
$phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']);
echo $phpAds_raw['html'];
}
?>

How can I execute this code on page if I'm using mod_rewrite for dynamic pages (page.cgi)?

I need to create new php file where I should put this code and then call this new php with with global_name or?

Regards.

P.S. This code is just example. I know I can use Remote call for PHPAdsNew :)

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
I would make a script like;

banner_code.php =>

Code:
<?php if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) { if (!isset($phpAds_context)) $phpAds_context = array(); $phpAds_raw = view_raw ('zone:3', 0, '_blank', 'front', '1', $phpAds_context); $phpAds_context[] = array('!=' => 'bannerid:'.$phpAds_raw['bannerid']); echo $phpAds_raw['html']; } ?>

...and then use the following global;

php_call =>

Code:
sub {
my $cmd = $_[0];
my $got = system($cmd);
return $got;
}

... and then call with;

<%php_call("/usr/bin/php /full/path/to/php/banner_code.php")%>

This is untested though, but should work ok.

Let me know how it goes :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
Nope, it doesnt work. Unsure

Got this error at the top of the page:
Code:
Content-type: text/html X-Powered-By: PHP/4.3.9 # ================================================================== # Links SQL - enhanced directory management system # # Website : http://gossamer-threads.com/ # Support : http://gossamer-threads.com/scripts/support/ # CVS Info : 087,071,092,086,082 # Revision : $Id: page.cgi,v 1.36 2001/12/30 19:33:05 alex Exp $ # # Copyright (c) 2001 Gossamer Threads Inc. All Rights Reserved. # Redistribution in part or in whole strictly prohibited. Please # see LICENSE file for full details. #
use strict; use lib '/home/public_html/cgi-bin/links/admin'; use Links qw/$CFG/; use Links::User::Page; local $SIG{__DIE__} = \&Links::fatal; Links::init('/home/public_html/cgi-bin/links/admin'); Links::init_user(); if (GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'check_request', \&Links::check_request)) { GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'handle_page', \&Links::User::Page::handle); }

And in place where I've put call I got zero (0).

Regards

UnReal Network
Quote Reply
Re: [deadroot] mod_rewrite and PHP In reply to
No idea I'm afraid :( I just use my phpAdsNew2 plugin, and get it to insert the IFRAME codes <G>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod_rewrite and PHP In reply to
Yes, I also use remote IFRAME call for displaying banners (don't have your plugin but full installation of phpAdsNew2 on my server). This is not problem. As I said, this is just example. Don't know will some other code (not phpAdsNew) work. Will try that later.

Thank you for your help.

Regards.

UnReal Network