I am testing gocart (http://gocartdv.com/) and I have installed it in a subfolder called vine-cart, http://www.icas-v.org/vine-cart.
The default controller loads fine but the rest of the controllers return an error 404 message. I have looked through all the similar problems and the possible solutions, implemented them and they don't seem to work.
Please have a look at my configuration settings:
/---------------------------------|.htaccess file settings|---------------------------------/
RewriteEngine On
RewriteBase /vine-cart
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(cart(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
###
# 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]
# 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>
/---------------------------------|Config.php settings|---------------------------------/
$config['base_url'] = 'http://www.icas-v.org/vine-cart/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
/---------------------------------|routes file settings|---------------------------------/
$route['default_controller'] = "cart";
//this for the admininstration console
$route['admin'] = 'admin/dashboard';
$route['admin/media/(:any)'] = 'admin/media/$1';
Ive been trying to debug this for days. Please help.
Can you try this htaccess code? remove rewritebase.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /vine-cart/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /vine-cart/ [L]
</IfModule>
What did you name your controller file?
Also it's a good practice to comment out lines on your .htaccess as you test them 1 by 1 if its causing issues.
Related
I have installed Yii2 advanced app and what i am trying to do now is to redirect this url htpp://site/admin to the backend ( admin ) side. What i tried so far is:
AddDefaultCharset utf-8
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# Make the backend accessible via url: http://site/admin
RewriteRule ^admin$ $admin.php [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteRule ^static - [L]
I am not familiar whit .htaccess and i am not pretty sure what is the right way. This code is what i found after googling. The .htaccess file is in the app/backend/web/.htaccess. Can you point me the right way? Thank you in advance!
easy :
RewriteEngine On
# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend)/web/ - [L]
# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^admin(/(.*))?$ backend/web/$2 [S=1]
# handle the case of frontend
RewriteRule .* frontend/web/$0
# Uncomment the following, if you want speaking URL
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+/web)/.*$ $1/index.php
I'm relatively new to Codeigniter and MVC. But, have successfully made two apps 'Locally'. While exploring, I found a way to remove 'Index.php' from the URL and also about custom routes. The .htaccess file that i have works like charm locally, but when trying to host it; there is a issue 505 internal server issue
Here is the first .htaccess code that i have (works locally) :-
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
When i use the code above there is an error. And, the app works only when .htaccess is removed. (I then have to use the inconvenient long URLs)
After a brief research and using different .htaccess without success, i asked one of my friends who has a Hosted CI app successfully running. He sends me a file which leads me the landing page without any problem; but, cant call any functions with/without using routing .i.e. If i use the custom routed URl (www.mySite.com/contact) then also it leads me to the landing page, the same with actual URL scheme (www.mySite.com/welcome/contact_page)
The new code here:-
<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 /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Using this code shows me the landing page but i cannot navigate any further from there. When i try to call a function the landing page reloads. This, I think is because of the last error Handling Code (ErrorDocument 404 /index.php)
Does anyone know what the solution the problem might be??
questions
Why doesnt the first .htaccess code work when hosted?
What may be the issue with the second available .htaccess file??
Do you guys have better .htaccess file? If yes, can you post it here??
Try this .htaccess (Codeigniter Recommended )
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
or
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
In application/config/config.php
$config['base_url'] = 'http://stackoverflow.com/';
$config['index_page'] = ''; # Should be empty
And make sure Controller name, Model names are in proper way. Bcz Linux Host is an Case-Sensitive.
I have a CodeIgniter install running in our root web directory that I copied into a subdirectory called /dev... I edited the config/config.php file to reflect the change so it is now like this:
$config['base_url'] = 'http://mysite.com/dev';
$config['sbase_url'] = 'https://mysite.com/dev';
$config['default_email'] = 'noreply#mysite.com';
$config['site_url'] = 'http://mysite.com/dev';
This is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
When I hover over any links on the site they are correct, for example the contact us page link reads www.mysite.com/dev/contact but when I click any of the links I get a 404 error...
Is there something common I am missing?
Enable FollowSymlinks & add a ./ in front of index.php in your RewriteRule:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# block hidden directories
RewriteRule "(^|/)\." - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
Also, I would leave blank $config['base_url'] = ''; & use the base_url() url helper when constructing links instead, which makes moving environments easier (e.g. subdir'd dev & root-level production).
... and of course, insure that ModRewrite is enabled in your Apache config.
I've got a problem trying to install Social Engine. Upload all files, set directory permissions, but when I enter my domain, I get a:
Not Found
The requested URL /install/install was not found on this server.
It's something related to the .htaccess files in root and install directory, 'cause removing them I do begin the installation process BUT with long URLs, this way:
/install/index.php/install
And that's something that would end up with all long URLS, instead of short ones that google use to index, for example. My ISP has safe_mode OFF, and mod_rewrite ON, so I'm just kinda lost...
.htaccess :
# $Id: .htaccess 7539 2010-10-04 04:41:38Z john $
<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]
</IfModule>
# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On
# #todo This may not be effective in some cases
FileETag Size
Had the same issue running SocialEngine on Vagrant (using https://box.scotch.io/) and fixed it by clearing the .htaccess file under /install/.
My current development is using CodeIgniter, and when I try to pass some parameters to index function of my main controller it returns me 404 error.
http://localhost/gis/1 -> 404 ERROR
http://localhost/gis/home/1 -> 404 ERROR
Actually my route.php file has a route like this:
$route['default_controller'] = "home";
$route['home/([:num])'] = 'home/index/$1';
My .htaccess file is this (from this post to take away index.php from CI urls):
<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_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>
And my config.php file:
$config['base_url'] = "http://localhost/gis";
$config['index_page'] = "";
What am I doing wrong? Thanks!
Update:
Quoting OP:
.htaccess wasn't guilty. The problem
was that my route needs to be
$route['home/(:num)'] = ... I added
both parenthesis and all works.
Rather than:
$route['home/([:num])'] = 'home/index/$1';
Try specifying it like this:
$route['home/:num'] = 'home/index/$1';
Also make sure that from application/config/routes.php, your default controller is set to home:
$route['default_controller'] = 'home';