I would need some help, I have go-dady hosting and sub-domain. I also have simple HTML website that is included in codeigniter system. The problem is that main page works (http://new.bendcare.com), but all sub-pages doesn't work, i get error:
No input file specified.
My base url in set:
$config['base_url'] = 'http://new.bendcare.com';
My current .htaccess is:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I found that I should add #Mod Rewrite on godady hosting to work correctly, but not in my case.
What should I change to make codigniter work on godady hosting ? I have no problems on other hosting's.
Just add the ? sign after index.php in the .htaccess file :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
And it would work !
Related
I have a WordPress site hosted on AWS and I am having a hard time to configure mod_rewrite to work correctly.
Folder structure
/root
|_ staging/
|_ live/
The .htaccess is the WordPress default
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Main Problem
I can access /staging/index.php/api which I used to access it without subdirectories like this ---.com/api.
When I try /staging/api it shows File not found.
I tried to change the .htaccess to different thing but none of them was successful.
There are no .htaccess file in the root directory.
Some help would be appreciated =)
Thanks in advance.
Try this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /staging
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /staging/index.php [L]
</IfModule>
Note: The AllowOverride should be set to All in server configuration.
You can find the reference from here.
How to Set AllowOverride all
I am totally new to Code igniter and dealing with form submissions through MVC archi. As, I searched and tried all soultions and code given on stack overflow itself to remove index.php from url but all of them didn't worked. I know something is missing and I am not able to recognize it as I am new to CI.
This is my .htaccess code below,
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I have also set $config['index_page']=' '; and $config['uri_protocol']='REQUEST_URI'; in config.php file.
NOTE: My CI version is 3x
Make sure your rewrite base is right like given in screen shot i have given. There are many htaccess files in each folder. I give the htaccess which is in red in the image and the structure also.
<IfModule mod_rewrite.c>
RewriteEngine On
# !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 /projectfolder //its an example
RewriteBase /project
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>
I use xampp and windows 10
Place in main directory of project not in the application folder.
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
Structure
application
system
user_guide
.htaccess
index.php
Try some of these also
https://github.com/wolfgang1983/htaccess_for_codeigniter
Don't for get to set base_url
$config['base_url'] = 'http://localhost/yourprojectname/';
$config['index_page'] = '';
I have seen other articles on the same issue. But none of the answers have solved my problem.
I am not using xampp or wamp but have setup php mysql apache seperately. Also I am using my own local domain for instance mytestsite.com.
My .htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /TestCI/
# Canonicalize Codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(HomeController(/index)?|index(\.php|html?)?)/?$ / [R=301,L]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=301,L]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|TestCI) [NC]
RewriteRule ^(.*)$ http://www.mytestsite.com/$1 [R=301,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>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
I have also made following changes in config.php
$config['base_url'] = 'http://mytestsite.com/TestCI/';
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO'; //AUTO
I have also made following changes in apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
But when i try to access
http://mytestsite.com/TestCI/HomeController/
its showing 404 error but works correctly when using
http://mytestsite.com/TestCI/index.php/HomeController/
I have looked into several similar questions that have been reported solved, but none of the answers have worked for me. Is there anything else that should be done to remove index.php from the url. Kindly respond back. Help highly appreciated.
It may be the htaccess isn't being used.
Put a sytax error in the file. (Append something like hdtbf to the file)
If that doesn't give a 500 error you need to turn allow override all
In your main Apache config
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Replace the following line of code in your .htaccess file
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Just put this code in your .htaccess :
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Thankyou for helping me... Problem is solved.
I made the following changes in my apache2.conf file
<Directory /Absolute path to .htaccess folder
AllowOverride All
Require all granted
</Directory>
Also I removed the RewriteBase parameter in .htaccess file which is where the actual pbm was.
My current .htaccess file looks like
<IfModule mod_rewrite.c>
RewriteEngine On
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I have also made changes in config.php where i changed $config['base_url'] to codeigniter root path
I am new to url re-writng and is currently facing problems with rewriting url for multiple applications in codeigniter. I have scanned the whole stackoverflow with some potential answers but it is still not solving my problems entirely
My directory at the root is as such
-application
--administrator
--frontend
What I am looking for is for my users to access my web site (frontend) with http://www.mydomain.com/ And my admin (backend) as http://www.mydomain.com/admin/
my current .htaccess is as such
<IfModule mod_rewrite.c>
RewriteEngine On
# If the user types just "admin".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin$ administrator.php [L,QSA]
# If the user enter in any admin section, like "admin/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin\/(.*)$ administrator\.php/$1 [L,QSA]
# If the user types any site section, like "site/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index\.php/$1 [L,QSA]
ErrorDocument 404 /index.php
</IfModule>
code from CodeIgniter multi-application .htaccess problem
I can get what I desire at the front end with the above .htaccess, but I can't get it working on my back end. Basically, www.domain.com/admin gives a 404 page not found error.
Please advice me on the problem. Also, please guide me on where I should place this .htaccess file? at the root? inside the application folder? or inside the frontend and administrator folder respectively.
Many thanks.
Regards.
Why not something like this in your root directory.
RewriteEngine on
RewriteCond $1 !^(index\.php|update\.php|assets|admin|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]
This will basically ignore any directories such as "admin" to route to the frontend application. You will have to set your config.php and remove index.php from the controller.
Found a way to work with this problem already. It is not a very smart way of doing it but it at least worked.
First, I created an 'admin' folder in the root, with a copy of the application's index.php
Which effectively make my directory looking like this.
-admin
--.htaccess
--index.php
-application
--frontend
--administrator
-index.php
-.htaccess
For this solution you will need to have two .htaccess files in different location.
For the .htaccess at the root, it should look like this.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|update\.php|administrator\.php|assets|admin|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
For the .htaccess in the admin folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
While this works on localhost, it is noteworthy that it may not work on rented servers because the file system in your host may be different.
I am a newbie at codeigniter. I have my codeigniter installed at localhost/path/learn_ci.
I have followed all the steps given in the codeigniter wiki. Here is my .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /learn_ci/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I've also changed the config file as required. But when I try to access
I get this error
"The requested URL /learn_ci/index.php/welcome was not found on this server"
I have double checked...the mod_rewrite module in Apache is on.
The RewriteBase solution also didn't work. Am I doing something wrong??
As others have said, make sure that AllowOverride is set to All in your apache config or your virtual host file.
Given the path that you have codeigniter setup in, your htaccess should look like this:
RewriteEngine On
RewriteBase /path/learn_ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path/learn_ci/index.php/$1 [L]
Also, remember that any assets you are using (img, css, js, etc) are referenced either with the base_url() function or using relative paths. The root of your project is going to be /path/learn_ci.
I find that it is easier to create a virtual host and add an entry to my hosts file locally. This mimics real life much better.
Try:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
You can do the following:
First in config.php file set
$config['index_page'] = '';
Next, create a .htaccess file in the codeigniter root folder and add the following content:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
Save the file. It should work.
You place the htaccess file in your root public_html folder in the same directory as index.php
Then remove /learn_ci from your htaccess file, just make it /index.php/$1
Check your apache config, it should be something like :
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
I thought to add my answere. My project base url is http://localhost/newproject/
I included htacess file in the newproject folder.
here is the code.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
then I change config file.
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
and every thing started to work. now nomore index.php file.