使用的.htaccess路由到codeigniter两个不同的应用程序路由、应用程序、不同、两个

2023-09-02 11:28:02 作者:爷、活的狠高调

我有两个codeigniter应用程序与此类似例如。我创建了两个的index.php 文件一样的例子说,(第二个被命名为oglasnik.php)。我想打电话给应用程序,而不调用所需的应用程序文件的名称。

我把这为我举个例子。所以,我的.htaccess文件现在的问题是:

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteBase / PublishWall /
    DirectoryIndex的indexl.php

    的RewriteCond%{REQUEST_URI} ^系统。*
    重写规则^(。*)$ indexl.php?/ $ 1 [L]

    的RewriteCond%{REQUEST_URI} ^应用。*
    重写规则^(。*)$ indexl.php?/ $ 1 [L]

    的RewriteCond $ l ^(indexl  .PHP | oglasnik  .PHP |图片|机器人 .TXT)!
    重写规则^ oglasnik $ oglasnik.php [L]

 < / IfModule>

 <!IfModule mod_rewrite.c>

    的ErrorDocument 404的index.php
 < / IfModule>
php_value date.timezone欧洲/卢布尔雅那
AddDefaultCharset UTF-8
 

在我的路线oglasnik我得到404页面没有找到,不应该这样的规则:

 重写规则^ oglasnik $ oglasnik.php [L]
 

改写为oglasnik.php。当我去oglasnik.php它工作正常。

另外,我珍玩找出如何路由actualy工作。是否重写URL访问.htacces文件再次,这是我看到的这个答案。

重写日志:

  127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3) perdir C:/ WAMP / WWW / PublishWall /]条每个DIR preFIX:C:/ WAMP / WWW / PublishWall / oglasnik  - > oglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(。*)$'到URIoglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](4)[perdir C:/ WAMP / WWW / PublishWall /]的RewriteCond :输入='/ PublishWall / oglasnik'模式='^系统*'=>不匹配
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]条每DIR preFIX:C:/ WAMP / WWW / PublishWall / oglasnik  - > oglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(。*)$'到URIoglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](4)[perdir C:/ WAMP / WWW / PublishWall /]的RewriteCond :输入='oglasnik'模式='!^(indexl  .PHP | oglasnik  .PHP |图片|机器人 .txt)的'=>匹配
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](4)[perdir C:/ WAMP / WWW / PublishWall /]的RewriteCond :输入='/ PublishWall / oglasnik'模式='^应用*。'=>不匹配
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]条每DIR preFIX:C:/ WAMP / WWW / PublishWall / oglasnik  - > oglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(oglasnik)$'到URIoglasnik
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](2)[perdir C:/ WAMP / WWW / PublishWall /]重写oglasnik - > oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](3)[perdir C:/ WAMP / WWW / PublishWall /]加每DIR preFIX:oglasnik.php  - > C:/wamp/www/PublishWall/oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](2)[perdir C:/ WAMP / WWW / PublishWall /]尝试更换preFIX C:/ WAMP / WWW / PublishWall /带/ PublishWall /
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](4)添加实名词preFIX:oglasnik.php  - > /PublishWall/oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#15b10d8 /初始](1)[perdir C:/ WAMP / WWW / PublishWall /]内部重定向与/PublishWall/oglasnik.php [内部重定向]
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]条每个DIR preFIX:C:/wamp/www/PublishWall/oglasnik.php  - > oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(。*)$'到URIoglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](4)[perdir C:/ WAMP / WWW / PublishWall /]的RewriteCond:输入='/ PublishWall / oglasnik.php'模式='^系统*'=>不匹配
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]条每个DIR preFIX:C:/wamp/www/PublishWall/oglasnik.php  - > oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(。*)$'到URIoglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](4)[perdir C:/ WAMP / WWW / PublishWall /]的RewriteCond:输入='oglasnik.php'模式='!^(indexl  .PHP | oglasnik  .PHP |图片|机器人 .txt)的'=>不匹配
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]条每个DIR preFIX:C:/wamp/www/PublishWall/oglasnik.php  - > oglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](3)[perdir C:/ WAMP / WWW / PublishWall /]应用模式'^(oglasnik)$'到URIoglasnik.php
127.0.0.1  -   -  [30 /月/ 2013:23:35:36 +0100] [本地主机/ SID#991d38] [摆脱#151b500 /初始/再导向#1](1)[perdir C:/ WAMP / WWW / PublishWall /]通过C:/wamp/www/PublishWall/oglasnik.php
 
图解路由器 当 交换机使用方法 x26amp 两者区别

解决方案

您可能想试试这个:

 的RewriteCond%{REQUEST_URI} ^(indexl  .PHP | oglasnik  .PHP |图片|机器人 .TXT)!
重写规则^ oglasnik。* $ oglasnik.php?/ $ 1 [L]
 

I have two codeigniter applications similar to this example. I've created two index.php files like the example says(the second one is named oglasnik.php). I want to call applications without the name of the file that calls the desired application.

I take this as an example for me. So the my .htaccess file right now is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /PublishWall/
    DirectoryIndex indexl.php

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ indexl.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ indexl.php?/$1 [L]

    RewriteCond $1 !^(indexl.php|oglasnik.php|images|robots.txt)
    RewriteRule ^oglasnik$ oglasnik.php [L]

 </IfModule>

 <IfModule !mod_rewrite.c>

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

When I route to oglasnik I get 404 Page Not Found, shouldnt this rule:

RewriteRule ^oglasnik$ oglasnik.php [L]

rewrite it to oglasnik.php. When I go to oglasnik.php it works fine.

Also I am curios to find out how this routing actualy works. Does the rewritten url visit the .htacces file again, something I see in this answer.

The rewrite log:

127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik' pattern='^system.*' => not-matched
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='oglasnik' pattern='!^(indexl.php|oglasnik.php|images|robots.txt)' => matched
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik' pattern='^application.*' => not-matched
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] strip per-dir prefix: C:/wamp/www/PublishWall/oglasnik -> oglasnik
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(oglasnik)$' to uri 'oglasnik'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (2) [perdir C:/wamp/www/PublishWall/] rewrite 'oglasnik' -> 'oglasnik.php'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (3) [perdir C:/wamp/www/PublishWall/] add per-dir prefix: oglasnik.php -> C:/wamp/www/PublishWall/oglasnik.php
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (2) [perdir C:/wamp/www/PublishWall/] trying to replace prefix C:/wamp/www/PublishWall/ with /PublishWall/
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (4) add subst prefix: oglasnik.php -> /PublishWall/oglasnik.php
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#15b10d8/initial] (1) [perdir C:/wamp/www/PublishWall/] internal redirect with /PublishWall/oglasnik.php [INTERNAL REDIRECT]
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/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 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik.php'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/initial/redir#1] (4) [perdir C:/wamp/www/PublishWall/] RewriteCond: input='/PublishWall/oglasnik.php' pattern='^system.*' => not-matched
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/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 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(.*)$' to uri 'oglasnik.php'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/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 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/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 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/initial/redir#1] (3) [perdir C:/wamp/www/PublishWall/] applying pattern '^(oglasnik)$' to uri 'oglasnik.php'
127.0.0.1 - - [30/Jan/2013:23:35:36 +0100] [localhost/sid#991d38][rid#151b500/initial/redir#1] (1) [perdir C:/wamp/www/PublishWall/] pass through C:/wamp/www/PublishWall/oglasnik.php

解决方案

You may want to try this one:

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