Before I open this post, I did spent three days try to figure out this, but no luck at all, so please help me out. Thanks~~~~
Ok, this is what I’ve done so far:
Then, I got this:
yes working: http://ci.dev/index.php/welcome/index
not working: http://ci.dev/welcome/index
Here are some details of what I have now:
.htaccess file:
# I got 500 error if I uncommend this line: <IfModule mod_rewrite.c>
#http://ci.dev/index.php/welcome/index this is works fine only if the above line commend out
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/?$1 [L]
# I got 500 error if I uncommend this line: </IfModule>
config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';
//$config['uri_protocol'] = 'REQUEST_URI';
host file
127.0.0.1 localhost
127.0.0.1 test.dev
127.0.0.1 ci.dev
httpd.conf file
#the following line also enabled
LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf
...
# The following code I placed at the bottom of https.conf file
NameVirtualHost *
<VirtualHost *>
ServerName localhost
DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>
<VirtualHost *>
ServerName ci.dev
DocumentRoot /Users/coda/Sites/ci
<Directory /Users/coda/Sites/ci>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName test.dev
DocumentRoot /Users/coda/Sites/test
</VirtualHost>
Please HELP ME OUT ~~~~
Thanks
=================================================================
Thanks everyone who try to help me out here. I finally got it works, I think somehow I overcomplicated things after overlooking something simple.
I just install another copy of CI2 and only change the .htaccess file with:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Then, it all works~!!!! –
Have the.htaccess file in the application root directory, along with the index.php file. (Check if the htaccess extension is correct , Bz htaccess.txt did not work for me.)
And Add the following rules to .htaccess file,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Then find the following line in your application/config/config.php file
$config['index_page'] = 'index.php';
Set the variable empty as below.
$config['index_page'] = '';
That's it, it worked for me.
If it doesn't work further try to replace following variable with these parameters ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') one by one
$config['uri_protocol'] = 'AUTO';
Note:
htdocs is the root folder
ci_intro is the code igniter's folder
if we have the same case, then your .htaccess should be like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Notice the RewriteBase /ci_intro/ change the ci_info to your codeigniter's folder.
Try this .htaccess (put this into root of the project directory i.e. /chat here):
# To remove index.php from URL
RewriteEngine On
# RewriteBase /chat
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Put RewriteBase
if you have project in a sub directory otherwise remove it
Try it :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /codeigniterNameFolder/index.php/$0 [PT,L]
change codeigniterNameFolder :)