CodeIgniter Forums
problem with rewritting - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: problem with rewritting (/thread-53384.html)



problem with rewritting - El Forum - 07-22-2012

[eluser]global_erp_solution[/eluser]
I tried to access web page using /servername/first/order.
my controller name is order_controller.php. so in my htaccess:
Code:
RewriteEngine On

RewriteCond $1 !^(index\.php|robots\.txt|css|js|pics)
RewriteRule ^(.+)$ /first/index.php/$1_controller [L]

and I got 404 page not found. the rewritelog:
Code:
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] strip per-dir prefix: D:/Apache/apache-httpd-2.2/apache-php-webapps/first/order -> order
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] applying pattern '^(.+)$' to uri 'order'
(4) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] RewriteCond: input='order' pattern='!^(index\\\\\\\\.php|robots\\\\\\\\.txt|css|js|pics)' => matched
(2) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] rewrite 'order' -> '/first/index.php/order_controller'
(1) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] internal redirect with /first/index.php/order_controller [INTERNAL REDIRECT]
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] add path info postfix: D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php -> D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php/order_controller
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] strip per-dir prefix: D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php/order_controller -> index.php/order_controller
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] applying pattern '^(.+)$' to uri 'index.php/order_controller'
(4) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] RewriteCond: input='index.php/order_controller' pattern='!^(index\\\\\\\\.php|robots\\\\\\\\.txt|css|js|pics)' => not-matched
(1) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] pass through D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] add path info postfix: D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php -> D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php/order_controller
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] strip per-dir prefix: D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php/order_controller -> index.php/order_controller
(3) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] applying pattern '^(.+)$' to uri 'index.php/order_controller'
(4) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] RewriteCond: input='index.php/order_controller' pattern='!^(index\\\\\\\\.php|robots\\\\\\\\.txt|css|js|pics)' => not-matched
(1) [perdir D:/Apache/apache-httpd-2.2/apache-php-webapps/first/] pass through D:/Apache/apache-httpd-2.2/apache-php-webapps/first/index.php

What's wrong? thanks


problem with rewritting - El Forum - 07-22-2012

[eluser]InsiteFX[/eluser]
.htaccess should be in the root folder with index.php

Code:
php_value default_charset utf-8

Options FollowSymLinks
Options -Indexes
DirectoryIndex index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]



problem with rewritting - El Forum - 07-22-2012

[eluser]global_erp_solution[/eluser]
but I have several web apps, and the other are not using CI. some are for cake. that's why I didn't put it in root.


problem with rewritting - El Forum - 07-22-2012

[eluser]InsiteFX[/eluser]
It goes in the root folder of your CodeIgniter installation were index.php is.



problem with rewritting - El Forum - 07-22-2012

[eluser]global_erp_solution[/eluser]
yes, index.php is inside "first" folder along with the rewrite. however, following security guide, the application and system folder are outside root. everything works just fine with this setting if the rewrite is disabled. anything wrong?


problem with rewritting - El Forum - 07-22-2012

[eluser]global_erp_solution[/eluser]
all of my controllers are suffixed with _controller, but I'm hoping by using rewrite, I can omit the _controller part. Even when I change my rewrite to this:
Code:
RewriteEngine On
RewriteRule ^order$ /first/index.php/order_controller [L]

/first/order still returned 404. Why is this?


problem with rewritting - El Forum - 07-22-2012

[eluser]global_erp_solution[/eluser]
solved it. Dunno what's wrong, but apparently some virus did this (or is it trojan?) did the trick. thanks for the help and thanks to my antivirus.


problem with rewritting - El Forum - 07-22-2012

[eluser]InsiteFX[/eluser]
Microsoft has every free now for Viruses if you run Windows.

Microsoft Security Essentials

And for Root Kits, Trojon's and Viruses:

Windows Defender Offline

And they also update their deffinition files two to three times a day and weekends.