1

I have multiple CI applications with two index files in the main directory of the CI project that point to the application directory(indexl.php && oglasnik.php). I have allready written a question about this problem before here.

What I would want to do is to route every request that goes to oglasnik to oglasnik.php.

Here is my .htacces file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /PublishWall/
    DirectoryIndex indexl.php
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ indexl.php?/$1 [L]

    RewriteCond $1 !^(indexl\.php|oglasnik\.php|images|robots\.txt)
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ indexl.php?/$1 [L]

    RewriteRule ^oglasnik$ oglasnik.php [L]

    </IfModule>

    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 
php_value date.timezone "Europe/Ljubljana"
AddDefaultCharset utf-8

RewriteRule ^oglasnik$ oglasnik.php [L] This should rewrite to oglasnik to oglasnik.php and it does, but when it does it points directly to the 404_override instead of the default controller, which is set OK, its works when I type locahost/PublishWall/oglasnik.php.

The rewrite log of the request:

127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik' pattern='^system.*' => not-matched
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='oglasnik' pattern='!^(indexl\.php|oglasnik\.php|images|robots\.txt)' => matched
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik' pattern='^application.*' => not-matched
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^oglasnik$' to uri 'oglasnik'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (2) [perdir C:/wamp/www/PublishWall/] rewrite 'oglasnik' -> 'oglasnik.php'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (3) [perdir C:/wamp/www/PublishWall/] add per-dir prefix: oglasnik.php -> C:/wamp/www/PublishWall/oglasnik.php
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (2) [perdir C:/wamp/www/PublishWall/] trying to replace prefix C:/wamp/www/PublishWall/ with /PublishWall/
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (4) add subst prefix: oglasnik.php -> /PublishWall/oglasnik.php
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#16bb100/initial] (1) [perdir C:/wamp/www/PublishWall/] internal redirect with /PublishWall/oglasnik.php [INTERNAL REDIRECT]
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik.php -> oglasnik.php
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik.php'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik.php' pattern='^system.*' => not-matched
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik.php -> oglasnik.php
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik.php'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='oglasnik.php' pattern='!^(indexl\.php|oglasnik\.php|images|robots\.txt)' => not-matched
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik.php -> oglasnik.php
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^oglasnik$' to uri 'oglasnik.php'
127.0.0.1 - - [31/Jan/2013:07:14:48 +0100] [localhost/sid#841d38][rid#173b580/initial/redir#1] (1) [perdir C:/wamp/www/PublishWall/] pass through C:/wamp/www/PublishWall/oglasnik.php

This should work, I think? But it does not. What does this pass through mean in the end of log, it happens also when I acces index.php which works fine.

Community
  • 1
  • 1
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
  • Do the sites have separate application folders? If so why not just use one index.php, and then put an `if else` around the `$application_folder` variable, changing it depending on the url. – Jeemusu Jan 31 '13 at 06:21
  • they have separate folder, how do I get the URL in the index.php, it is rewritten before?? – Borut Flis Jan 31 '13 at 07:47
  • 1
    I would just use `$_SERVER['HTTP_HOST']` . For example `if($_SERVER['HTTP_HOST'] == "www.mysite.com" || $_SERVER['HTTP_HOST'] == "mysite.com") { $application_folder = 'application1';} else { $application_folder = 'application2'}` – Jeemusu Jan 31 '13 at 08:06
  • $_SERVER['HTTP_HOST'] returns the name of the host this is localhost in my example. This seems like a very hackish way, I think I will explore the mod_rewrite even more. – Borut Flis Jan 31 '13 at 08:49
  • Oh, I see, sorry I didn't realise your sites ran off the same host. – Jeemusu Jan 31 '13 at 08:50

0 Answers0