Why can I not remove index.php from codeigniter URL - codeigniter

I have a new installation of Kubuntu 15.10 with old (working) code from my site.
Somehow I can not get rid of the index.php in the URL.
I tired dozens of suggestions but nothing seems to work.
My current status is this:
Apache 2 have mod_rewrite on:
printout of php_info()
Apache2 config is:
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
My .htaccess is located under application folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
What am I missing here? I am loosing faith... :-P

Step 1: In your .htaccess replace all other codes..try with this:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Step 2: Move your .htaccess from application folder to where index.php located.
Step 3: Change in your config.php
From:
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';

Try it in application/.htaccess, index.php will exists in url but in scripts it will be ignored.
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

Related

apache setup .htaccess rewriteRule with laravel

im setting up (laravelproj/public/.htaccess)
the example ones that I've worked on 2 different servers as follows:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://takaful.hsn93.com/$1 [R,L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
now I'm trying it on cent OS apache (httpd) (if that matters)
and when i put in the link (http://example.com/) < apache returns the following:
i dont have any other problem except this link ^ with no parameters ^
Forbidden
You don't have permission to access / on this server.
so to make it work i'd to comment this line (condition where it checks if the requested isnt directory:
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
which make sense because / is of course a directory ..
but why did this .htaccess configuration worked on all other machines?
what is different on this machine that makes this condition returning a forbidden from apache
i found the problem is that httpd.conf
doesnt index (index.php) files just (index.html)
so i modified it
<IfModule dir_module>
DirectoryIndex index.html
DirectoryIndex index.php
</IfModule>

Renaming index.php in the htaccess in codeigniter

I want to rename the index.php in the htaccess file which I used for removing the long url, I renamed index.php to main.php, this is because of hacker overwriting my index.php.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php
#controller, previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^CI_System.*
RewriteRule ^(.*)$ /cacworldwide/main.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends
#the request to cacworldwide/main.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cacworldwide/main.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to main.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /cacworldwide/main.php
</IfModule>
Simply, following lines would solve your problem
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cacworldwide/main.php/$1 [L]
</IfModule>

.htaccess file for magento in subdirectory

We are finding it difficult to remove the redirection of my /admin to /index.php/admin, which is not allowing us to access the admin panel, at every url that should start with /admin/ gets redirected to /index.php/admin/ and it displays No input file specified. and when i remove index.php from the url it works fine.
My .htaccess file looks like this
DirectoryIndex /new/magento-k/index.php
RewriteEngine on
RewriteBase /mysubdirectory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_URI} !^/admin.*
RewriteCond %{REQUEST_URI} ^/index.php/admin.*$
RewriteRule ^/index.php/admin(.*) /admin$1 [R]
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^/index.php/(admin|user)($|/) - [L]
Options -MultiViews
Try putting this into your .htaccess file
RewriteRule .* /index.php [L]
and remove the other index.php rule:
RewriteRule ^/index.php/(admin|user)($|/) - [L]
Also make sure to clear cache of Magento and your browser.

Remove index.php from URL

I am using Codeigniter 2.1.0 and to remove index.php from url I follow Codeigniter 2.0.0
but it does not work for me. Actually my web application url is
http://localhost/my_site/admin/index.php/users
and I want
http://localhost/my_site/admin/users
Hi Sajid I used below code try I may be it will solve your problem.
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /your_folder/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]
And don't forget to open your configuration file (application/config/config.php) and edit the following two options:
$config['base_url']
$config['index_page']
You just need to create .htaccess file in project folder and write:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#And You don't need to define in base_url in config file:
$config['base_url'] = '';// blank it.
I hope it will work perfectly ...

CodeIgniter - removing index.php

Im having some trouble removing the index.php thing on my CI install, the current .htaccess im using is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
My CI install is back from the public_html directory and i have changed the config to
$config['index_page'] = "";
So my CI looks like the following
/core-1.7.3
/public_html/index.php
When i type the url i get the 404, but when i put index.php in front of it, it works fine :S
Im confused
Hi
I ve installed that 1.7.3 and this .htaccess worked with this URL-
/CodeIgniter_1.7.3/public_html/welcome
.htaccess->
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Work through Avisek Chakraborty's comment and make sure you've done them all, but
it sounds to me like you don't have mod_rewrite installed correctly.
Make sure it is by using the following test:
http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
It is written for windows but you should get the idea.
If it doesn't work then install mod_rewrite and try again.
Also try to change this:
$config['uri_protocol'] = “REQUEST_URI”
You need the FollowSymLinks directive for .htaccess rewrites ...
Options Indexes FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
The Options directive is in The Apache Docs

Resources