Code Igniter configuration without index.php, how to configure code igniter without index.php in url
Tag- How to configure code igniter without index.php in url
Add Following in your custom domain. suppose your domain name is xyz.com and your apache configuration file for the same id xyz.conf
then add below given->
1)
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/devendra.kumarsingh/CodeIgniter"
ServerName xyz.com
ServerAlias www.xyz.com
RewriteEngine On
<Directory /Users/devendra.kumarsingh/CodeIgniter/>
AllowOverride All
Require all granted
</Directory>
#ErrorLog "/private/var/log/apache2/xyz.com-error_log"
#CustomLog "/private/var/log/apache2/xyz.com-access_log" common
</VirtualHost>
1A) Change DocumentRoot according to your path
1B) Change your ServerName and ServerAloias
1C) Change Directory
2) Enable below-given modules in you httpd.conf file-'
A) LoadModule rewrite_module libexec/apache2/mod_rewrite.so
B) LoadModule php7_module libexec/apache2/libphp7.so
Change php7_module according to your php version
C) Add you local domain configuration file in your httpd.conf file as-
Include /etc/apache2/extra/xyz.conf
Include /etc/apache2/extra/xyz.conf
3) Create a .htacces file in your route folder of code igniter, contents are-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
4) Edit your config file- /application/config/config.php as-
//$config['base_url'] = '';
if ($_SERVER['HTTP_HOST']=='localhost'){
$config['base_url'] = 'xyz.com'/;
}else{
$config['base_url'] = 'xyz.com/';
}
5) Check your /application/config/route.php
$route['default_controller'] = 'home';// default home page controller called
6) Add an entry in /etc/hosts
127.0.0.1 xyz.com
7) Restart apache server- sudo apachectl restart
Remove index.php in apache2 --
1) Add "ReWriteEngine On" in your /sites-available/xyz.com.conf
2) sudo ln -s ../mods-available/rewrite.load
Sometimes we need to do the following in our apache conf file-
<VirtualHost *:80>
ServerName xyz.com
DocumentRoot /var/www/html/xyz
<Directory /var/www/html/xyz>
Options +FollowSymLinks -Indexes
AllowOverride All
Require all granted
</Directory>
CustomLog /log/apache-log/xyz_log common
ErrorLog /log/apache-log/xyz_error_log
</VirtualHost>
1) Add "ReWriteEngine On" in your /sites-available/xyz.com.conf
2) sudo ln -s ../mods-available/rewrite.load
Sometimes we need to do the following in our apache conf file-
<VirtualHost *:80>
ServerName xyz.com
DocumentRoot /var/www/html/xyz
<Directory /var/www/html/xyz>
Options +FollowSymLinks -Indexes
AllowOverride All
Require all granted
</Directory>
CustomLog /log/apache-log/xyz_log common
ErrorLog /log/apache-log/xyz_error_log
</VirtualHost>
Comments
Post a Comment