Jump to content

[SOLVED] Apache to PHP


DataRater

Recommended Posts

I'm using apache to map something like

 

www.something.com/firstpage/ to index.php in the top web directory.

I also want to map

www.something.com/secondpage/ to index.php

 

inside index.php I want to be able to say

 

if www.something.com/firstpage/ then include firstpage.php

or

if www.something.com/secondpage/ then include secondpage.php

 

Have you any idea how I can find the original request i.e. www.something.com/firstpage/ from inside index.php?

 

 

 

Link to comment
Share on other sites

hi,

i'm not sure, but this info could be available as $_SERVER['REQUEST_URI'], if not and you're using mod_rewrite for your redirect, you could pass the originating url as query parameter to index.php.

 

hope this helps,

 

  stefan

Link to comment
Share on other sites

Hi DataRater,

ok, if $_SERVER['REQUEST_URI'] is after the rewrite i would suggest passing the url as query parameter. A common pattern (to me, at least) is a rewrite config like this in an .htaccess file:

 

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>

 

The two conditions check if there is a physical file or directory matching the url, if so no rewrite takes place, otherwise the request is rewritten to index.php and the original request path is passed as get parameter 'url' to index.php.

 

Cheers,

 

  Stefan

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.