Removing index.php CodeIgniter using WAMP shows Wampserver Homepage instead - codeigniter

I just started learning CodeIgniter and I want to remove the index.php so the URL can be shown nicely.
I'm using .htaccess but instead it shows me the Wampserver Homepage (like in http://localhost)
My project directory is in http://localhost/CodeIgniter
What's wrong?

If anyone is still looking for this answer, it is due to not enabling mod_rewrite in the httpd.conf file.
Just remove the # from the start of the below line in the httpd.conf file to enable mod_rewrite.
LoadModule rewrite_module modules/mod_rewrite.so
Restart the apache after that.

Only three steps are require to remove index.php from url in Codeigniter in WAMP environment.
1) Create .htacess file in parallel to application holder and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable “rewrite_module” of apache.
Restart your apache and its done.
Details : http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/

Related

The requested URL was not found on this server' in XAMPP; Used Answers in Other Threads

I am using the latest version of CodeIgniter and XAMPP. I have searched stackoverflow and followed te suggestion from other threads with the same problem, to no avail.
I have several CI projects running oin my localhost b(each with their own CI install). I recently started a new project and went through the following steps to remove index.php from appearing in the URL:
Changed $config['index_page'] = "index.php" to
$config['index_page'] = '' in config.php
Changed $config['uri_protocol'] = "AUTO" to
$config['uri_protocol'] = "REQUEST_URI" in config.php.
Updated the .htaccess file to the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Restarted apache
Yet I am still getting this error.
I have confirmed that mod_rewrite is installed in my XAMPP config. Plus, I am using rewrite rules for the other projects on my locolhost and they are working fine. I also made sure that update the base_url in the config: $config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/folder_name';
I have tried variations on the .htaccess file that I have found in other answers, yet an still at a loss. I've done this before; what's different!?
EDIT: I am only getting this error when trying to explicitly go to a controller/method. I have the default controller set to my login controller, so going to http://localhost/folder_name correctly hits the Login/login() controller/method. However, if I change the url to go to http://localhost/folder_name/login/login, I get the 404 error. However, http://localhost/folder_name/index.php/login/login/ eorks just fine still.
I my self use XAMPP. and windows 10
Inside your project folder place the htaccess
htdocs > folder_name
htdocs > folder_name > .htaccess
Here is one I use
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Then on the config.php
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
$config['base_url'] = 'http://localhost/folder_name/';
$config['index_page'] = '';
Some case you will need to make sure you have the class and filename set where only the first letter is upper case. Explained here naming classes and here filenames
Add RewriteBase with your project folder name.
Change your .htaccess to
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project_folder_name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Remove index.php codeIgniter in xampp mac os 10.9 not work

I already develop a system in windows base machine using xampp and codeIgnitor, So i change development environment to mac os 10.9 same system give me error 404. So putting index.php to the URL the issue fixed. But I wonder how it's happen. Cause I already remove index.php using htaccess file in windows environment. I want to know how I remove index.php in mac os 10.9.
This is my htaccess file content.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
/Applications/XAMPP/xamppfiles/etc/httpd.conf
File also edited as follows
enable rewrite module "LoadModule rewrite_module modules/mod_rewrite.so"
change username
User ******
Group daemon
change permissions
AllowOverride All
Require all granted
CodeIgnitor config file also edited as follows
- change base url
$config['base_url'] = 'http://localhost/ci2.2/';
- Remove index.php
$config['index_page'] = '';
- Change URL Protocol
$config['uri_protocol'] = 'AUTO';
I put my files in /Applications/XAMPP/xamppfiles/htdocs/ci2.2 directory
Try this htacess content:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Reference: http://ellislab.com/codeigniter/user-guide/general/urls.html
If you are using a subdirectory, replace the last line by this:
RewriteRule ^(.*)$ /[SUBDIRECTORY]/index.php/$1 [L]
Replace [SUBDIRECTORY] by your the directory name
In my case following code works fine
RewriteEngine On
RewriteBase /projects/hc/homecare/trunk/homecare
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]
ref : link

How to remove index.php in Wamp?

I 've been using CodeIgniter in XAMPP.
There was no problem to redirect to a function URL (e.g., function1):
http://localhost/function1
When I changed to WAMP, I got a problem. I could not redirect to function1. However, function1 is still accessed at:
http://localhost/index.php/function1
How to configure WAMP and CodeIgniter to remove index.php?
In order that I could run function1 as I run using XAMPP.
Thank you.
Please try the following:
1) Create .htaccess file in parallel to application folder and just copy paste the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable "rewrite_module" of apache. Click on WAMP symbol -> Apache -> Apache modules -> rewrite_module
Now you can access your site without index.php in url.
Create an .htaccess file if you didn't already have one and add this code in it:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Make sure you place this in the same directory as your index.php.
Only three steps are require to remove index.php from url in Codeigniter in WAMP environment.
1) Create .htacess file in parallel to application holder and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable “rewrite_module” of apache.
Restart your apache and its done.
Details : http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/
The mod_rewrite rule suggested in CodeIgniter's official documentation at http://ellislab.com/codeigniter/user-guide/general/urls.html which is
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
worked perfectly for me on WAMP
This would also work:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
In these two variations, the only difference is the condition. Basically, what matters is the rewrite rule. Condition can depend on your requirement.
Both of these were not working for me earlier on WAMP. However, the problem was in Apache settings. rewrite_module was not enabled. So, do check that is enabled. You can check if it is enabled by using phpinfo() and check the Loaded modules list.
If you it is not enabled, you can enable it using the WAMPserver manager (accessing it from task bar) Go to Apache>Apache Modules and check 'rewrite_module'
OR
Open httpd.conf and check if LoadModule rewrite_module modules/mod_rewrite.so is uncommented.
You will have to restart WAMPserver to activate the changes.

CodeIgniter Rewrite URL: remove index.php from url

My apps url is
http://localhost/myapp/admin/index.php/projects
and I want to rewrite it as
http://localhost/myapp/admin/projects
I followed user guide
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
for this but not work for me.
Please follow these steps:
1- If you work on localhost please enable mode_rewrite in php.ini
2- Create a .htaccess file under project folder and paste this (please change 'project' to your project folder name):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /project/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>
3- Edit this line at application/config.php:
$config['index_page'] = "";
Thank /* ActuallyMAB */: Your code actually works. The above code works on localhost (WAMP Server on windows).
If you have placed your codeigniter project in some folder such as your directory structure looks like:
C:\wamp\www\proposal
So, You have to replace
RewriteRule ^(.*)$ /project/index.php/$1 [L]
to
RewriteRule ^(.*)$ /proposal{or your folder name}/index.php/$1 [L]
if this is not the case with your project {you have put your codeigniter directly into www folder}, then remove the folder name from the above code as it looks like;
RewriteRule ^(.*)$ /index.php/$1 [L]
also do not forget to change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
in your config folder {config.php}
I hope others have also provided the same answer, but since the above code works in my project and i felt to provide some details too.

mod_rewrite for codeIgniter

Has anybody in the history of the internet and web development, been able to get rid of the "index.php" with mod_rewrite in codeIgniter.
I've been trying for several days now and nothing seems to work.
I'm using this one (in .htaccess file):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Not sure where I got it but it works for my codeigniter install, local and live. Don't forget to set $config['index_page'] = ''; in your config file.
For mod_rewrite use the following in your .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If your codeigniter instance is running in a subdirectory then use the rewrite base command before the RewriteRule
RewriteBase /subdirectory/
Then set
$config['index_page'] = '';
In the config file.
You might have your .htaccess file in the wrong place. CodeIgniter has a default .htaccess placed in the applications folder, which I mistakenly took for the one I should edit.
You actually need to create a new .htaccess under the root folder. So not code_igniter/applications/.htacces...but code_igniter/.htaccess
Hope this helps.
Yes, I configured it under Linux using the instructions from here. However, I configured it via httpd.conf instead of using .htaccess.
I have used the settings provided above and they always worked - unless I did not have mod_rewrite enabled.
If you are having issues check to ensure you have mod_rewrite enabled. If you do not it will not matter what you put into .htacess or your Apache config

Resources