この例に似た 2 つの codeigniter アプリケーションがあります。例のように2 つのファイルを作成しましたindex.php
(2 番目のファイルは oglasnik.php という名前です)。目的のアプリケーションを呼び出すファイルの名前なしでアプリケーションを呼び出したい。
私はこれを例として取り上げます。したがって、現在の .htaccess ファイルは次のとおりです。
<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
olasnik にルーティングすると、404 Page Not Found が表示されますが、次のルールではいけません。
RewriteRule ^oglasnik$ oglasnik.php [L]
olasnik.php に書き換えます。oglasnik.php にアクセスすると、問題なく動作します。
また、このルーティングが実際にどのように機能するかを知りたいと思っています。書き換えられた URL は .htacces ファイルに再度アクセスしますか。これは、この回答で確認できます。
書き換えログ:
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