3
votes

I am starting a new project in codeigniter. While setting up work folder in localhost i put the following htaccess file in my project root folder for remove index.php from the url

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

now i am getting the error message as follows

"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request."

my project path is localhost/sc

in the config.php file i put the following line

 $config['base_url']='http://localhost/sc';

server error message is " Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration"

I am using wamp server in windows platform please help me to solve this problem

Thank you

6
have you enabled rewrite module in apache?Ramesh
yes i do it now ..but now page not found error!! when i am not using index.php in the url ...is there any problem with the .htaccess fileChinthu

6 Answers

8
votes

This .htaccess script works perfectly for me. Place it within the first set of folders inside your project directory. Same level as the index.php file

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

The error 500 can be checked on the apache error.log file using the following path /var/log/apache2/error.log

Check the last error listed and fix it.

5
votes

See this question: .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

Essentially, you need to turn on mod_rewrite. That's why you're getting the " Invalid command 'RewriteEngine' error message.

Additionally, since you're project path is in /sc/ you need to set you base to /sc/:

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

And place the htaccess file in the /sc/ folder.

3
votes

Activate a rewrite_module in your WAMP. It comes disabled by default

2
votes

I had the same issue a year ago. 1. First and foremost, make sure that mod_rewrite module is enabled in your apache server ( Apache -> Apache Modules -> Rewrite_module [Just select] Or else See "Apache error log" under Apache Menu in wampserver to know more about the error). Don't waste time for other solution.

2. Secondly, that might be because of htaccess rules. Kindly, use this basic line of code for htaccess.
 Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 

0
votes

In CodeIgniter, If you are calling a model that tries to fetch values from a table that doesn't exist, you may face a 500 - internal server error.

0
votes

Activate Rewrite_module in wampserver Like Apache -> Apache Modules -> Rewrite_module [Just select] Or else See "Apache error log" under Apache Menu in wampserver to know more about the error