I have added into htaccess file some rules in order to remove index.php from the url in Code Igniter . However, for just one address it is not working
the url is like this "http://example.com/subtitle/eveythingelse/";
so when the second uri is "subtitle" or "sub" it doesn't send to "index.php" and directly reads the folder which doesn't exist.
if I change the second uri "http://example.com/changed/everythingelse" it works.
I am really confused about.
this is code of .htacce :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
It's because with final /
RewriteCond %{REQUEST_FILENAME} !-d
Test if the directory exist, and don't do rewrite.
You can delete this condition.
Related
Anyone can help with my htaccess file, its working with the root domain directory folder only, if i put the index file into the root domain directory and access page like this https://example.com/edr/login , it works nicely . However when i create folder inside it and try to access site like this , https://example.com/createdfolder/edr/login, it says 'No input file exist. Below is my htaaccess file codes. My $_SERVER['QUERY_STRING'] is set to 'login'
Options All -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f [NC]
RewriteRule ^(.*)$ $1.php [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
If to copy WordPress' .htaccess it would look like this:
RewriteEngine On
RewriteBase /createfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /createfolder/index.php [L]
Of course you can replace createfolder/ with your/path/
I recently moved my codeigniter application from a subdomain to operate under my domain.
Basically I moved it from:
https://account.mywebsitehere.com
To:
https://mywebsitehere.com/account
Now when I try to access anything like /invoices it removes the /account from the url and results in a not found page. I have changed the base url in the config file but it is still resulting in this error.
Other than going through the entire application and changing every link to be /account/... How can I make the application work under the /account in the url?
My .htaccess file located at public_html/panda/.htaccess is as follows:
RewriteEngine on
RewriteCond $1
!^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mywebsitehere.com/panda/$1 [R,L]\
Try to change base_url to:
$config['base_url'] = 'https://mywebsitehere.com/account';
just put that code in .htaccess file and try it
RewriteEngine On
RewriteBase /account/
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]
first, upload an image to the root directory and see if you can access it within the browser.
if you cant access it , check your server's configuration and your .htaccess file.
Before you tell me to go to CodeIgniter multi-application .htaccess problem, hear me out.
The reason I say that is because my problem seems to be nearly the exact same as this posters. My directory structure is:
application/
admin/
app/
..
.htaccess
admin.php
index.php
The htaccess rules are:
RewriteEngine On
RewriteBase /dev/
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 ^admin$ admin\.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin\/(.*)$ admin\.php/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index\.php/$1 [L,QSA]
Essentially what I need is:
type in example.com/admin - the url keeps the admin folder, and redirect the user to admin.php
type in example.com/admin/controller/method - same as above
type in example.com/anything_else - the user gets directed to the app instead of admin (index.php)
In testing the person in the aforementioned post's htaccess, which mine are essentially copied from, in an online tester, the two rules involving URIs with 'admin' in it are not passed for some reason. I can only get admin (not ^admin$) to work as a pattern (according to the tester).
RewriteRule ^dev/admin(\/?) admin.php? [L,QSA]
Should do it for you. This will account for /admin, /admin/ and /admin/whatever/here. But for the latter, be aware that since you have QSA on it will append it to the destination URL like so: /admin.php?whatever/here.
I've got a codeigniter setup where all URLs redirect to index.php, like below.
I need /api/index.php to go to /api, but NOT through a redirect.
My code below matches api/index.php but it is still not working.
/index.php/api works fine, and goes to the correct URL, however /api/index.php just goes to a 404 error page... Any suggestions? Am I being silly?
RewriteEngine on
RewriteBase /
RewriteRule ^api/index.php$ /index.php/api [L]
RewriteCond $1 !^(index\.php|images|robots\.txt|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]
Probably because it is looking for a file named /api/index.php
Add these Rewrite Conditions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
//Your rewrite rule here
Try this:
RewriteEngine on
RewriteCond $1 !^(index\.php|img|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Pages are currently available at the following addresses:
http://www.domain.co.uk/solutions/article/page-name1
http://www.domain.co.uk/solutions/article/page-name2
http://www.domain.co.uk/solutions/article/page-name3
etc
..but I would like them to be accessible via the following addresses in order for enhanced SEO:
http://www.domain.co.uk/solutions/page-name1
http://www.domain.co.uk/solutions/page-name2
http://www.domain.co.uk/solutions/page-name3
So, I think I want to use mod_rewrite in the .htaccess file of the site root to add the 'article' directory after the solutions directory on each incoming page request. I have been looking for a suitable answer for about a month and I've tried learning the mod_rewrite basics tutorials but I just can't make this work for me so apologies for another mod_rewrite question.
This is my .htaccess file at present:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>
I'm doing something similar on a site of mine. Here's the .htaccess rules I'm using to remove index.php and show the shortened url:
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(css|js|gif|jpe?g|png|ico) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
RewriteCond %{REQUEST_URI} ^/solutions/(.*) [NC]
RewriteRule ^(.*) /solutions/article/%1 [L]
Remember that the URL you see in your browser's address bar is not the URL that ExpressionEngine sees - EE sees {segment_2} as "article".
Edit :
Try this :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^solutions/article/
RewriteRule ^solutions/(.*)$ /solutions/article/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>