How to remove index.php in Wamp?

I am using CodeIgniter in XAMPP. There was no problem redirecting to the function url (e.g. function1 ):

http://localhost/function1 

When I switched to WAMP, I had a problem. I could not redirect to function1 . However, function1 is still available:

 http://localhost/index.php/function1 

How to configure WAMP and CodeIgniter to remove index.php? So that I can run function1 when I start using XAMPP.

Thanks.

+6
source share
4 answers

Try the following:

1) Create a .htaccess file parallel to the 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 an empty space in config.php in the application folder, as shown below:

 $config['index_page'] = ''; 

3) Turn on the " rewrite_module " apache. Click on WAMP symbol -> Apache -> Apache modules -> rewrite_module

Now you can access your site without index.php in the url.

+10
source

Create a .htaccess file if you do not already have one and add this code to it:

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

Make sure you place it in the same directory as your index.php .

+2
source

To remove index.php from only three steps from the url in Codeigniter in the WAMP environment.

1) Create the .htacess file parallel to the application holder and simply copy 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 the application folder, as shown below:

 $config['index_page'] = ''; 

3) Enable "rewrite_module" for apache.

Restart your apache and its execution.

Details: http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/

+2
source

The mod_rewrite rule proposed in the official CodeIgniter documentation at http://ellislab.com/codeigniter/user-guide/general/urls.html , which

 RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] 

worked fine for me on WAMP

This will 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 options, the only difference is the condition. In principle, the rewrite rule is important. The condition may depend on your requirement.

Both of them did not work on WAMP before. However, the problem was in the Apache settings. rewrite_module was not included. So check to see if this is turned on. You can check if this is allowed with phpinfo () and check the list of loaded modules.

If you are not included, you can enable it using the WAMPserver manager (access to it from the taskbar). Go to Apache> Apache Modules and check the "rewrite_module" box

OR

Open httpd.conf and check if LoadModule rewrite_module modules/mod_rewrite.so uninhibited.

You need to restart WAMPserver to activate the changes.

+2
source

Source: https://habr.com/ru/post/951630/


All Articles