Reputation: 312
i am new in php & codeigniter.i am working on a project which was running in a server abcd.com
and i am using htaccess code like this
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
now my project has been moved to another server 192.000.000.000.
i can access the login page, when the user is logged in session is getting set and it is redirecting to 192.000.000.000/myproject/user
and here i am getting 404 error
i have been set base_url in config.php is like this
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['index_page'] = '';
my WINSCP Project structure
old one : /home/my_org/public_html/prjFolder
new one : /var/www/html/prjFolder
my .htaccess file like this
system/
application/
user_guide/
index.php
.htaccess
if anyone find solution please help me..
Upvotes: 4
Views: 219
Reputation: 312
I find the solution , It is the problem of apache rewrite_module. I changed my httpd.conf file and now its working perfect.
Change AllowOverride None
to AllowOverride All
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and Restart the Apache daemon using putty # service httpd restart
Reference Url : - http://dev.antoinesolutions.com/apache-server/mod_rewrite
Upvotes: 0
Reputation: 3
I think your problem in the destination pointed by your rewrite rule
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
If you are accessing your project through the URL
192.000.000.000/myproject/user
The rewrite rule will change this to
192.000.000.000/index.php/myproject/user
You need to modify your rewrite rule to exclude myproject/user from the url to be pass to index.php or you can just remove the .htaccess if this is only a dev machine, the reason my we hide the index.php is so that the url will look pretty. Having it on the dev environment wouldn't hurt at all.
Upvotes: 0
Reputation: 340
You mention that your project was moved to another server. Did you check if the AllowOverride directive (assuming you're using Apache as your web server) is set in your virtual host? If this is disabled, Apache will simply ignore your .htaccess file. A quick test is putting some nonsense in your .htaccess file that would certainly generate an error. If you don't get a server error, your .htaccess file is being ignored.
Link:http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Another cause could be that the mod_rewrite module is not enabled (again, assuming you're using Apache). You don't say if your pasted .htaccess code is your complete .htaccess file, so I don't know if it's checking if that module exists. A simple test to check if this is the cause, is trying the resulting url of the rewrite: 192.000.000.000/index.php/myproject/user
Link:http://httpd.apache.org/docs/current/mod/mod_rewrite.html
I am assuming you don't have any errors in your .htaccess file, since you seem to say that it worked fine before the move.
Upvotes: 2