1

I am facing problem while removing index.php from url in Codeigniter 3 using Wamp Server. I was changes in file config.php (project_folder/application/config/config.php)

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = "REQUEST_URI";

and create .htaccess file same level of application folder with code written

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# If your website begins from a folder e.g localhost/my_project then 
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

and rewrite_module is on and my virtual host code is

<VirtualHost *:80> 
    DocumentRoot "D:/work/project_Name/" 
    ServerName abc.local 
    <Directory "D:/work/project_Name/"> 
       Order Allow,Deny
       Allow from all
       Require all granted
    </Directory>
</VirtualHost>

using these changes and code my project not run without index.php and error throw

abc.local/controllername
Not found
The requested URL /controllername/ was not found on this server.

Thanks!

2
  • 1
    Read this tutorial w3code.in/2015/09/… Commented Nov 13, 2015 at 8:55
  • the above said problem has solved by change in virtual host file httpd-vhosts.conf ( C:\wamp\bin\apache\apache2.4.9\conf\extra ).By replacing "Order Allow,Deny" into "Allow from all" Cheer! Commented Nov 13, 2015 at 9:21

2 Answers 2

1

Try this code on .htaccess file

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

And on config.php page set $config['base_url'] ="http://localhost/project/" and $config['index_page'] = ''; and $config['uri_protocol'] = 'AUTO';

Sign up to request clarification or add additional context in comments.

1 Comment

click on Wampserver and select apache->httpd.conf and remove # from #LoadModule rewrite_module modules/mod_rewrite.so. Finally Restart Wamp Server
1

Try these:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /folder_name_of_project/


    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
    RewriteCond $1 !^(index\.php|images|stylesheets|javascript)
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.