Hi i'm using Codeigniter V2 and try to rewrite url
So i have done this steps :
I have htaccess file with following code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^asset.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^upload.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
And at config file i change config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO';
This my link website
http://www.beacukaitarakan.com/berita/berita.html
from active url
http://www.beacukaitarakan.com/index.php/berita/berita.html
but with those htaccess file, http://www.beacukaitarakan.com/berita/berita.html will not go to http://www.beacukaitarakan.com/index.php/berita/berita.html but always showing homepage
It can be work if i use QUERY STRING instead of config uri protocol but i have some setting eg. navigation that use this setting
http://www.beacukaitarakan.com/berita/berita.html?p=true&start=1
so i need to use path info rather than QUERY STRING
thanks in advanced
simply copy and paste the below code in the .htacces file.
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/
Related
1) I wanted to get rid of the bootstrap (index.php) name in the URL. I've been in YouTube searching and downloading lots of videos related to this, but none of them worked. This is the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
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>
I tried everything I could get on the Internet.
2) I couldn't load the files in the public folder where I store my JavaScript, CSS and image files. Path: codeigniter/application/.
What I tried:
<link rel="stylesheet" href="<?=base_URL() ?>public/css/default.css />
And the same for JavaScript files.
3) Routing problems(confusion). My default route us the dashboard controller. But I also wanted to create a login route. So I did this:
$route['login'] = 'login';
But this still routes to the default route when I go to localhost/codeigniter/index.php/login.
Try these .htaccess
# -FrontPage-
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$0 [PT,L]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Use this code in .htaccess file and also remove index.php from your config.php file e.g. $config['index_page'] = '';
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I recently moved to godaddy Linux hosting and the .htaccess doesn't seem to work. Are there any settings which need to be done for godaddy because the .htaccess was working on local xampp server as well as hostek server.I am getting "404 Not Found" error message.i am using CodeIgniter-2.2.1 framework also i have check mod_rewrite in Loaded Modules in php.ini file was not found enable from server side .
My htaccess file located on root directory where my application is deployed.
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Please suggest.
This is work for me:
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
change your
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
to like
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
use this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
in config.php
$config['base_url'] = "";
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
EDIT 01
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Working one on Godaddy shared:
RewriteEngine on
RewriteBase /
Options -Indexes
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/\?$1 [L]
<ifmodule mod_rewrite.c>
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path_to/your_website/index.php?$1 [L,QSA]
</IfModule>
I'm trying to redirect one directory on my site to https. The directory is not really a directory at all because the site's dynamic. I'm using ExpressionEngine as the CMS.
I already have a few lines in my .htaccess file to remove the index.php ExpressionEngine adds to all of its urls.
Here's what I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://mysite.com/store/$1 [R,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
When I visit, http://mysite.com/store/, it returns https://mysite.com/store/store/.
I think it might have to do with the following:
RewriteRule ^(.*)$ /index.php?/$1 [L]
The above line has a question mark after the index.php because I was getting a "No input file" error, and that was the recommended fix.
Any thoughts?
This line here:
RewriteCond %{REQUEST_URI} store
Should have a ! in front of "store":
RewriteCond %{REQUEST_URI} !store
because you don't want it to redirect if the URI is already /store.
Edited the line:
RewriteRule ^(.*)$ https://mysite.com/store/$1 [R,L]
to read:
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
Now it works. Here's the full code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
I'm trying to get my htaccess file not to rewrite my static files (js/css/images).
This is my current htaccess file:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !\.(jpg|css|js|gif|png)$ public/ [L]
RewriteRule !\.(jpg|css|js|gif|png)$ public/index.php?url=$1
How do I rewrite it?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$ [NC]
RewriteRule ^(.*)$ public/index.php?url=$1
All requests to not existing files which doesn't end with listed extensions (case nonsensitive match) are rewritten to public/index.php passing the current URL as url= GET argument
This only works for the one line below it. So if you have many RewriteRules it could help to use something like this:
RewriteEngine on
RewriteRule ^(.*?)\.(php|css|js|jpg|jpeg|png|pdf)$ - [L]
RewriteRule ^(.+)/(.+)/?$ index.php?page=$1&subpage=$2 [L]
RewriteRule ^(.+)$ index.php?page=$1 [L]
for posterity.
Maybe my rules will be useful
\www\.htaccess
#file: \www\.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(css|js|html?|png|gif|jpg|jpe?g|svg|xls.?|pdf|docx?|eot|ttf|woff2?)$ [NC]
RewriteRule (.*\.[css|js|html?|png|gif|jpg|jpe?g|svg|xls.?|pdf|docx?|eot|ttf|woff2?]+) public/$1?a [QSA,L]
RewriteCond %{REQUEST_URI} \.(css|js|html?|png|gif|jpg|jpe?g|svg|xls.?|pdf|docx?|eot|ttf|woff2?) [NC]
RewriteRule (.*\.[css|js|html?|png|gif|jpg|jpe?g|svg|xls.?|pdf|docx?|eot|ttf|woff2?]+) public/$1 [QSA,L]
#RUN TEST
RewriteCond %{REQUEST_URI} !\.(css|js|html?|png|gif|jpe?g|svg|xls.?|pdf|docx?|eot|ttf|woff2?)$ [NC]
RewriteRule ^(.*)$ index.php?REQUEST_FILENAME=%{REQUEST_FILENAME}&date=$1&REQUEST_URI=%{REQUEST_URI} [QSA,L]
#END TEST
RewriteRule . index.php?url=%{REQUEST_URI} [QSA,L]
ErrorDocument 404 index.php?error=404
\www\index.php
<?php
// file: /www/index.php
var_dump($_GET);
\www\app\.htaccess
#file: \www\app\.htaccess`
RewriteEngine On
RewriteRule ^(.*)$ ../_%{REQUEST_URI} [QSA,L]
\www\public\.htaccess
#file: \www\public\.htacces`
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=%{REQUEST_URI}&rewrite=$1 [QSA,L]
/www/public/index.php
<?php
// file: /www/public/index.php
var_dump($_GET, __DIR__);
I'm facing a problem with a cakephp application.
On my server, I have a folder called DIGIPRESSKIT (this folder is used by the domain www.digipresskit-online.com), I placed all the cake's folders into it and when I load the page, there is no CSS, like cake can't access my webroot.
Is there any chance u check my .htaccess ?
I read lots of forums about that, and here is what they tell me to do :
Code: "root/.htaccess" (/DIGIPRESSKIT)
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
Code: "root/app/.htaccess" (/DIGIPRESSKIT/app)
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
Code: "root/app/webroot/.htaccess"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
Assuming you can have many domains on this host, you can try this solution:
.htaccess on servers root (/)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} digipresskit-online.com
RewriteCond %{REQUEST_URI} !^/DIGIPRESSKIT
RewriteRule ^(.*)$ one/$1 [L]
RewriteRule ^$ / [L]
RewriteRule (.*) /$1 [L]
</IfModule>
.htaccess on subfolder (/DIGIPRESSKIT)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
DIGIPRESSKIT/app and DIGIPRESSKIT/app/webroot/ no change