How can I reliably get an html path with .htaccess 'RewriteBase'

This is a discussion on How can I reliably get an html path with .htaccess 'RewriteBase' within the PHP Language forums, part of the PHP Programming Forums category; Hi, if I have a site htt://www.example.tdl/folder1/folder2/page.html I want to get the folders ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-27-2007
FFMG
 
Posts: n/a
Default How can I reliably get an html path with .htaccess 'RewriteBase'


Hi,

if I have a site

htt://www.example.tdl/folder1/folder2/page.html

I want to get the folders from the root, so the folder would be
$f = './folder1/folder2/'
and the page
$p = 'page.html'

I have 2 problems:
First if the user does not enter a page
htt://www.example.tdl/folder1/folder2/
How can I reliably get the folders and page?
$f = './folder1/folder2/'
$p = ''

And secondly if I use RewriteBase in my .htacess, (I do that a lot).
RewriteBase /folder1/

the user would enters still enter
htt://www.example.tdl/folder1/folder2/
but the 'root' folder would now be '/folder1/'

How can I then get the right path.
$f = './folder2/'
$p = ''

Because if I use $_SERVER['REQUEST_URI'] then it will return
$f = '/folder1/folder2/page.html'

Thanks.

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14214

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

Reply With Quote
  #2 (permalink)  
Old 04-27-2007
Toby A Inkster
 
Posts: n/a
Default Re: How can I reliably get an html path with .htaccess'RewriteBase'

FFMG wrote:

> htt://www.example.tdl/folder1/folder2/page.html
>
> I want to get the folders from the root, so the folder would be
> $f = './folder1/folder2/'
> and the page
> $p = 'page.html'


Something like this?

<?php
$components = explode('/', $_SERVER['REQUEST_URI']);
$p = array_pop($components);
$components[] = '';
$f = implode('/', $components);
?>

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Reply With Quote
  #3 (permalink)  
Old 04-27-2007
FFMG
 
Posts: n/a
Default Re: How can I reliably get an html path with .htaccess 'RewriteBase'


Toby A Inkster;62002 Wrote:
> FFMG wrote:
>
> > htt://www.example.tdl/folder1/folder2/page.html
> >
> > I want to get the folders from the root, so the folder would be
> > $f = './folder1/folder2/'
> > and the page
> > $p = 'page.html'

>
> Something like this?
>
> <?php
> $components = explode('/', $_SERVER['REQUEST_URI']);
> $p = array_pop($components);
> $components[] = '';
> $f = implode('/', $components);
> ?>
>


I guess that would work solving the first problem.
but how can I fix the second problem?

I can I tell what the value of 'RewriteBase' in my .htaccess is?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=14214

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

Reply With Quote
  #4 (permalink)  
Old 04-27-2007
Toby A Inkster
 
Posts: n/a
Default Re: How can I reliably get an html path with .htaccess'RewriteBase'

FFMG wrote:

> I can I tell what the value of 'RewriteBase' in my .htaccess is?


Open the file and parse it?

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Reply With Quote
  #5 (permalink)  
Old 04-27-2007
fel
 
Posts: n/a
Default Re: How can I reliably get an html path with .htaccess 'RewriteBase'

use fopen, fread fclose and a write a simp0le .htaccess parser.

On Apr 27, 6:19 am, FFMG <FFMG.2pp...@no-mx.httppoint.com> wrote:
> Toby A Inkster;62002 Wrote:
>
>
>
> > FFMG wrote:

>
> > > htt://www.example.tdl/folder1/folder2/page.html

>
> > > I want to get the folders from the root, so the folder would be
> > > $f = './folder1/folder2/'
> > > and the page
> > > $p = 'page.html'

>
> > Something like this?

>
> > <?php
> > $components = explode('/', $_SERVER['REQUEST_URI']);
> > $p = array_pop($components);
> > $components[] = '';
> > $f = implode('/', $components);
> > ?>

>
> I guess that would work solving the first problem.
> but how can I fix the second problem?
>
> I can I tell what the value of 'RewriteBase' in my .htaccess is?
>
> FFMG
>
> --
>
> 'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
> (http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
> (http://www.insurance-owl.com/other/car_rec.php)
> 'Free URL redirection service' (http://urlkick.com/)
> ------------------------------------------------------------------------
> FFMG's Profile:http://www.httppoint.com/member.php?userid=580
> View this thread:http://www.httppoint.com/showthread.php?t=14214
>
> Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).



Reply With Quote
Reply
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

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




All times are GMT +1. The time now is 04:41 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0