delete index.php file from url - Codeigniter - php

this is my link :
http://vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/index.php/welcome
I would like to remove index.php from url.
my .htaccess file :
/Pannel
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.vitrinsaz1.ir
RewriteRule ^.*$ http://www.vitrinsaz1.ir%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>
$config['index_page'] = '';
$config['base_url'] = 'http://vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/';

Try this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
for more read this http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/

Add ? after index.php in last rule so your .htaccess would be like
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.vitrinsaz1.ir
RewriteRule ^.*$ http://www.vitrinsaz1.ir%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

You can try this settings ;
$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
$config['base_url'] = '';
And .htaccess ;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html
if it does not work try this link ;
http://www.formget.com/codeigniter-htaccess-remove-index-php/

Related

Codeigniter can't remove index.php

i really need help,
same as the title, my problem is can't remove index.php in my codeigniter
i had try many .htaccess code like :
// first
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectFolderName/ --> i already change to my project name
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
//second
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
//third
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^(.*)$ index.php/$1 [NC,L]
//fouth
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
i had change my config like
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
in some reference
in my httd.conf
<Directory />
AllowOverride All
Require all denied
</Directory>
i move the .htaccess to main project folder (not in application)
but all doesn't work
You forget to set base_url in application/config/config.php.Set your base_url.
$config['base_url'] = 'your_url';
In root folder .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
And also
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Working fine here..
That funny,
my url: http://localhost/Igniter
in my config:
$config['base_url'] = 'http://localhost/igniter';
you can be the same me, check url with link "igniter" replace "Igniter'

Want to generate redirct rule for htaccess

I am having trouble to generate redirection rule I tried so many possible ways but those are not working.
Here are the details:
1) Current link: https://app.abcd.com (Showing in url)
2) Redirect to: https://app.abcd.com/index.php/login
3) Should be renamed as : https://app.abcd.com/login
I have tried :
RewriteEngine on
RewriteRule (.*) http://https://app.abcd.com/index.php/login/$1 [R=301,L]
Didn't work!
Any help!
You can use this :
RewriteEngine on
RewriteRule ^$ /index.php/login [L,R]
This will redirect your homepage / to /index.php/login
You can also accomplish this using RedirectMatch
RedirectMatch 301 ^/$ /index.php/login/
Try it.
Options +FollowSymlinks
Options -Indexes
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteEngine on
RewriteBase /example/
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) index.php/$1 [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)/([^?]*) index.php?_cmd_=$1/$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_cmd_=$1 [L,QSA]
.htaccess for codeigniter:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And in config.php:
change:
$config['index_page'] = "index.php";
to:
$config['index_page'] = "";
HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Open config.php and do following replaces
$config['index_page'] = "index.php"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
IndexIgnore *
Try to add this in your .htacces file:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]

Codeigniter can't remove index from url

I am Using CentOS,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteBase /var/www/html/site/
</IfModule>
but geting same problem my pages with index.php works fine but when i remove index.php
it's not working...
I think it will help you as i am using this one.Put this code in your root folder's htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Please let me know if it is working or not.
This can be a few things.
1( remove the index page from your config file (application/config/config.php)
$config['index_page'] = '';
2( Do you have base_url like this:
$config['base_url'] = 'http://yourdomain.com/';
Note the / at the end.
3( try this .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
Simple at your config.php file at your config folder search for index url (index_page) and make it empty
$config['index_page'] = '';
Try this it works for me ccnd is my files folder.
RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|images|css|js|lib|img|bootstrap|robots\.txt)
RewriteRule ^(.*)$ /ccnd/index.php/$1 [L]
RewriteEngine On
RewriteBase /site_root/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Important:
1. you must set $config['index_page'] = ''; in config.php file.
2. site_root is folder name like, wamp/www/site_root.

.htaccess RewriteRule error

I have these lines in .htaccess.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Now, I'd like to add the following into the .htaccess, so I can redirect all users to http://www.mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
So, I just added the code above in my existing .htaccess file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
RewriteRule . index.php
But, It doesn't work as I expect.
Please teach me how I am supposed to write in this case.
Thanks so much in advance!!
You should redirect to the www subdomain first, then forward the request to your index.php file. Try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.).+$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

PHP url rewriting using htaccess

http://www.example.com/justridesbeta/jstride/vehicle
to
http://www.example.com/justridesbeta/addride
using htaccess.
Currently using
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]
# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
RewriteRule ^[a-zA-Z0-9]+$ justridesbeta/jstride/vehicle
</IfModule>
if ($_SERVER['REQUEST_URI'] == '/justridesbeta/jstride/vehicle')
{
header("Location: http://www.example.com/justridesbeta/addride");
exit;
}
if you really need that

Categories