0

first of all sorry for my bad english

here my background of this problem : i have 2 project using codeigniter 1 project created by team a name project : client_site another one created by team b name project : server_site

the structure directory on prod mechine is :
---- www
-------- application(folder)
-------- system(folder)
-------- .htaccess
-------- server_site(folder)
--------------- application(folder)
--------------- system(folder)
--------------- .htaccess

the problem start today, suddenly when admin cannot log in to the server site( at 9.00am) when admin submit the login panel, it said that page not found (404), suddenly can log in again at 12.00pm and this evening at 17.00pm admin cannot log in again, but not problem for client site, they still can access add / edit / add item, only happen to server site

i don't understand why, or maybe i got wrong code for the application but when i check the controller and function it's already there controller home.php with function login()

my bos said, my htaccess maybe got wrong setting

here my htaccess :

on root site(client_site):

RewriteEngine on <br/>
RewriteCond %{REQUEST_FILENAME} !-f<br/>
RewriteCond %{REQUEST_FILENAME} !-d<br/>
RewriteCond $1 !^(index\.php|images|font|banners|buttons|css|detik|js|robots\.txt|favicon\.ico)<br/>
RewriteCond $1 !^(index\.php|application/views/|robots\.txt|install|favicon\.ico|documents)
RewriteRule ^(.*)$ /index.php?/$1 [L]<br/>
RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]<br/>
RewriteRule ^(.*)$ http://www.client_site.net/ [R=301,L]<br/>

on server_site :

RewriteEngine on <br/>
RewriteCond %{REQUEST_FILENAME} !-f<br/>
RewriteCond %{REQUEST_FILENAME} !-d<br/>
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)<br/>
RewriteCond $1 !^(index\.php|application/views/|robots\.txt|install|favicon\.ico|documents)<br/>
RewriteRule ^(.+)$ index.php?/$1 [L,QSA]<br/>
RewriteCond %{HTTP_HOST} !^www\.<br/>
RewriteRule ^(.*)$ http://www.[%]{HTTP_HOST}/server_site/$1 [R=301,L]<br/>

some one, can u help me?

Beni kurniawan
  • 101
  • 1
  • 2
  • 12

1 Answers1

1

On the server side, you have two issues

RewriteRule ^(.+)$ index.php?/$1 [L,QSA]

this differs from the client side by .+ vs .*, index.php vs /index.php and L,QSA vs L.

The second point might be more serious, [%]{HTTP_HOST} will not work, because it is not substituted. You must use %{HTTP_HOST} instead

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/server_site/$1 [R,L]

When everything works as you expect, you can change R to R=301. Never test with 301 enabled, see this answer Tips for debugging .htaccess rewrite rules for details.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • hi olaf, yes, on server side, i write wrong code to post here, my bad sorry, i already use the same as u mention :) but thx "RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/server_site/$1 [R=301,L]" so it's better for using R than R=301? R it means redirect right? how about error 404? do you have a suggestion or maybe about some thing else? – Beni kurniawan Apr 16 '13 at 08:25
  • @Benikurniawan Both `R` and `R=301` mean redirect, it's just a different status code. See updated answer. – Olaf Dietsche Apr 16 '13 at 09:15