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
https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/
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
https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-598328
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.