Codeigniter URL rewriting .htaccess is not working on CentOS
You need to also specify the locations that can use it. For example, in /etc/httpd/conf/httpd.conf you should see something like:
<Directory "/var/www/html">
...lots of text...
</Directory>
Make sure is has:
<Directory "/var/www/html">
AllowOverride All
</Directory>
CodeIgniter htaccess and URL rewrite issues
There are 3 steps to remove index.php
.
Make below changes in
application/config.php
file$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';Make
.htaccess
file in your root directory using below codeRewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]Enable the rewrite engine (if not already enabled)
i. First, initiate it with the following command:
a2enmod rewrite
ii. Edit the file
/etc/apache2/sites-enabled/000-default
Change all
AllowOverride None
toAllowOverride All
.Note: In latest version you need to change in
/etc/apache2/apache2.conf
fileiii. Restart your server with the following command:
sudo /etc/init.d/apache2 restart
Codeigniter mod rewrite in CentOS
On my CentOS I only have this:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
But my site resides in /var/www/html
. I am by no means an expert on Apache, but perhaps you need to set the
RewriteBase /home/virtual/site777/somefolder/var/www/html/
As well
CodeIgniter .htaccess index.php rewrite not working on user directory
Well, I found a solution in codeigniter forums, first I need to add RewriteBase line as follows:
RewriteBase /~userdir/myproject/
Then, remove the slash before index.php on last line.
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Someone said that
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
is redundant, the following two lines of code cover it,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
and all other real files/directories. They basically say "if the request is not for a REAL file, and the request is not for a REAL directory, pass the request to index.php. Presumably everything from the above line is a real file or directory, so it's not needed at all.
So, my final .htaccess is like this:
RewriteEngine on
RewriteBase /~userdir/myproject/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
It works well locally with http://localhost/~userdir/myproject also on production with http://example.com/~userdir/myproject
.htaccess is not working apache
.htaccess
is turned off by default
Directives in .htaccess files can override the settings in the main Apache configuration file, but by default that feature is turned off. To use htaccess, it needs to be turned on in the main Apache configuration file.
If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo
or AllowOverride All
Related Topics
Coreos - Get Docker Container Name by Pid
Which Stack Is Used by Interrupt Handler - Linux
How to Get Notified for Ip Address Changes Automatically
How to Prefill Command Line Input
Option to Display Control Characters in Gedit
The Meaning of Real, User, and Sys in Output of Linux Time Command
Using the Universal Chess Interface
Shell Script Working Fine Without Shebang Line? Why
How to Split a Ca Certificate Bundle into Separate Files
Ssh Command Execution Hangs, Although Interactive Shell Functions Fine
Can't Run Uwsgi as Root, "Bind(): Permission Denied"
Running R Scripts or Commands with Interpretor in Unix for Unix-Layman
How to Echo a Sum of a Variable and a Number
Trying to Find All the Kernel Modules Needed for My MAChine Using Shell Script
Automatically Kill Process That Consume Too Much Memory or Stall on Linux
How to Pass an Environment Variable to a Netbeans Makefile on Ubuntu
How to Flush Cache of Hard-Disk and Flash-Disk (Or Filesystem) from Command Line