Remove index.php when access using ip address - php

I uploaded codeigniter project on server.Removing index.php from URL is not working. I access it using IP address. like http://ip address/
Below is my htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
/etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I tried all possible solutions found on google. but not working for me.

Please follow some step:
goto application/config/config.php :
replace $config['index_page'] = 'index.php'; to $config['index_page'] = '';
and
$config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO';
enable rewrite mode by
sudo a2enmod rewrite
then
service apache2 restart
if you'd like, you can use the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

in httpd.conf, edit or delete "index.php":
<IfModule dir_module>
DirectoryIndex index.php
</IfModule
Then in htaccess, add this:
Options -Indexes

Add below code in .htaccess. Hope this work.
Options All -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Set your .htaccess as below
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Then open /etc/httpd/conf/http.conf file and find <Directory "/var/www/html"> with in this find and set AllowOverride None to AllowOverride All.

Related

How to remove index.php from URL in CodeIgniter using .htaccess

I know this question is asked many times before and I've gone through most of them already but couldn't find a solution. I've tried most of the answers given here, here and in CodeIgniter official documentation. And restarted apache each time. It didn't work for me. mod_rewrite is already enabled in my apache server.
Weird thing is, I've a working example for WAMP (in my laptop):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /project/index.php
</IfModule>
It works perfectly in WAMP, but it doesn't work in LAMP. Any kind of help is appreciated.
Please use below code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I have used this and it is working.
Try Below code in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ROOT DIRECTORY NAME/
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<Directory "/path/to/document/root/">
AllowOverride All
Allow from All
</Directory>
Just like this......
.htaccess inyour root directory with following code..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Set configuration in application/config.php as follows..
$config['base_url'] = 'http://domain_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I made it working with the help of following .htaccess code:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
And I updated <Directory /var/www/> section of /etc/apache2/apache2.conf file with:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
It solved all problems and now it works fine.
here it is my approach:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
And also in config.php replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
and also in the same file replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"

htaccess RewriteRule doesn't work properly

I have this code in my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?link=$1 [L]
</IfModule>
And I am getting 404 although I can acces it with non-pretty url like this index.php?link=somepage
My full url is http://www.website.com/subfolder/index.php?link=somepage
I have Apache 2.4.18 on Ubuntu 16 and mod_rewrite module is loaded.
Update
Also when I try with this:
RewriteRule ^ index.php [L]
Then I can access it with http://www.website.com/subfolder/?link=somepage
So this way it works when just removing index.php
Is it possible that some additional configuration has to be set on server?
This was a server issue including mime types and multiviews.
It's not really issue for stackoverflow but if someone runs into same problems here are sources that solved this problem:
http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm - remove MultiViews from Virtual Host configuration
https://serverfault.com/questions/372733/apache-file-negotiation-failed - add missing mime types
Try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/index.php?link=$1 [L]
Try with this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./index.php?link=$1
First of all you should check your apache config
sudo vi /etc/apache2/apache2.conf
Search for
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change AllowOverride None to AllowOverride All
enable htaccess module by running cmd
sudo a2enmod rewrite
then restart your server
sudo service apache2 restart
and use this .htaccess file in your project folder
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
Hope it works for u .. :)

Remove index.php from url in codeigniter-3 in ubantu14.04

I have Ubantu 14.04 machine also I checked Link
My phpinfo() says rewrite_module is Enable also I have done changes into config.php
$config['index_page'] = '';
and below is my .htaccess file on root
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Try this one
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
I got solution just added
<Directory /var/www/html >
Order allow,deny
AllowOverride All
Allow from all
Require all granted
</Directory>
into file /etc/apache2/sites-available/000-default.conf and it's working fine

Installing codeigniter on subdomain but it is giving 500 internal server error

I have installed the codeigniter on subdomain like http://abc.domain.com.
I have modified my htaccess file but it is giving 500 internal error. Please
tell me required changes to be done in htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /abc
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Change the RewriteBase to / only and add base_url to your config file like,
# in htaccess change the RewriteBase
RewriteBase /
in application/config/config.php
$config['base_url'] = 'http://abc.domain.com/';
Also make sure that your htaccess file should be in your abc folder, not on the root www
Firstly I hope you have configured your virtual host properly.
For example:
<VirtualHost *:80>
ServerName abc.domain.com
DocumentRoot /var/www/html/abc/or/whatever/
</VirtualHost>
And your Directory directive
<Directory /var/www/html/abc/or/whatever/>
AllowOverride all
</Directory>
Then place this in the /var/www/html/abc/or/whatever/.htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index.php|images|captcha|css|js|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
This should work in most cases. And don't forget to restart apache!

Laravel get rid of /public path in wamp

I'm using Laravel on WAMP server.
I have a hard time to get rid of /public/ in the URL path.
I found many workarounds on the web but no solution is working for me. I changed my .htaccess, my httpd.conf,... tried to make a symbolic link through windows console, but still nothing working.
Here's my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^localhost:8080/blog$ [NC,OR]
RewriteCond %{HTTP_HOST} ^localhost:8080/blog$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hereafter my httpd.conf
# Alias for Laravel public directory
Alias /Lara/ "C:/Bitnami/wampstack-5.4.31-0/apache2/htdocs/blog/public/"
<Directory "C:/Bitnami/wampstack-5.4.31-0/apache2/htdocs/blog/public/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Categories