Re: Apache odd behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-02-16 at 20:34 +0000, Stuart wrote:
> 2009/2/16 Paul M Foster <paulf@xxxxxxxxxxxxxxxxx>:
> > On Mon, Feb 16, 2009 at 07:30:57PM +0200, Thodoris wrote:
> >
> >>
> >>> I'm submitting a url like this:
> >>>
> >>> http://mysite.com/index.php/alfa/bravo/charlie/delta
> >>>
> >>> The index.php calls has code to decode the url segments
> >>> (alfa/bravo/charlie/delta). It determines that the controller is alfa,
> >>> the method is bravo, and converts charlie and delta to $_GET['charlie']
> >>> = 'delta'. It verifies that the controller and method exist, and calls
> >>> the controller and method.
> >>>
> >>> This works fine. The right controller gets called and the right method,
> >>> and the GET parameter looks like it should. The method sets some
> >>> variables and then calls a render() function to render the page, which
> >>> is in the doc root of the site.
> >>>
> >>> The page does get rendered, but without the stylesheet, and none of the
> >>> graphics show up. Why? Because, according to the logs, Apache appears to
> >>> be looking for the images and everything else in the directory
> >>> index.php/alfa/bravo/charlie/delta, which of course doesn't exist.
> >>>
> >>> No, I don't have an .htaccess file with RewriteEngine on. Apache figures
> >>> out that index.php is the file to look for in the original URL, but
> >>> can't figure out that everything else is relative to that file, not the
> >>> entire URL.
> >>>
> >>> This method is in use in at least one other MVC framework. What am I
> >>> doing wrong?
> >>>
> >>> Paul
> >>>
> >>>
> >>
> >> I assume that in order for this to work you will have to use mod_rewrite
> >> for apache to work properly. Check the framework's installation
> >> instructions to see if you configured mod_rewrite correctly for this to
> >> work properly.
> >
> > mod_rewrite isn't involved. Apache has a "lookback" feature that "looks
> > back" through the URL until it finds an actual file it can execute,
> > which in this case is index.php. Unfortunately, it appears that Apache
> > believes the directory in which linked files are found is the *whole*
> > URL.
> >
> > mod_rewrite might resolve this, but it isn't allowed on all servers. So
> > it's not a reliable solution.
> 
> This is your problem, you're not understanding where the paths are
> being resolved. Apache has absolutely no involvement in resolving
> relative paths in your HTML files to absolute URLs. The browser does
> this. All you need to do is use absolute URLs and everything will work
> fine. By absolute, in case you don't know, I mean starting with a /
> and being "from" the document root in the web server.
> 
> For example, if you have a tag like <a href="arse.php">arse</a> and
> arse.php is in the same directory as index.php you need to change it
> to <a href="/arse.php">arse</a>.
> 
> Another example... if you have <a href="somedir/crack.php">crack</a>
> where crack.php is in the subdirectory somedir beneath where index.php
> is you need to change the tag to <a
> href="/somedir/crack.php">crack</a>.
> 
> You need to apply this to all URLs in your code, including
> stylesheets, images and javascript references. This should not be a
> difficult concept to grasp, so maybe I'm not explaining it right. If
> so please explain what you understand by what I'm saying and I can
> alter it to be more helpful.
> 
> -Stuart
> 
> -- 
> http://stut.net/
> 
I've read through this thread and not noticed anyone mention the <base>
tag. This allows you to specify a URL to which relative ones are mapped
to, which could be just what you're looking for, as I believe all the
browsers support it (the tag has been around for donkeys years, so I'd
be surprised if any browsers didn't support it)


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux