CodeIgniter Flexi Auth Demo is Not working - php

I have just installed Flexi Auth Plugin on my Linux system by exactly following the Installation Guide
When I navigate to code http://localhost/codeigniter/ It is displaying the fancy demo page. However, when I click on "Demo" Link from top menu, Its displaying page not found error
Not Found
The requested URL /auth_lite/demo was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
Do I need to configure my routes.php? In the installation guide, It says only to edit the default controller like this $route['default_controller'] = "auth_lite/index";
By the way, I am very new to CodeIgniter. If any one encountered this problem, please help me.

search source-files for 'flexi_cart',
especially in three *library.php files,
there are some string-entries, that have to be
changed to your own directory.
Seems to work with that changes.

It does sound like your .htaccess file is either not working or not set as it should.
The server is looking for the filepath /auth_lite/demo where it should be passing that string to index.php.
Here's one of the most common .htaccess files for CI. Try it and see:
<IfModule mod_rewrite.c>
RewriteEngine On
# developing in a subfolder? (http://localhost/app/) change this to app/
RewriteBase /
#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
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|swf|wymeditor|galleries|ffeiliau)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Try it and see.

Related

PHP CodeIgniter (how to make public folder)

I'm a new in CodeIgniter.
I made public folder, where I want to put my css/js/images folders.
My setup is like that:
application
cache
config
controllers
public
css
js
images
....
....
....
My .htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /moviesmvc/
#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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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>
# 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>
how can I make this public folder public?
/////////////////////////
You really don't want to put your public folder inside your application folder. Your directory structure should be like this
-- application
-- system
-- public
-- css
-- js
-- images
-- index.php
-- .htaccess
This is the best practice to follow and you will save yourself a lot of time and potential problems in the future
If it's a Linux server then you need to change the folder permissions to 755 or 777. Have a Google around for this and you will get a lot more detail.
I would recommend not using CI at the minute as it isn't being developed on any more until they find a new owner. Instead, I would recommend Laravel as it's such an amazing framework, but you should also try out CakePHP, Symfony, Yii or something else which is still being developed.
Check Your Public Folder Permission as well as use base_url() function to get the public url..
for example
echo base_url('public/images'); to get image public path
I would not advise to implement this type of design and here is why:
Web servers are designed to not allow public access below the document root. This aides in both ease-of-setup and security.
If a major security change is made within the root then it has to be duplicated to your public folder.
You are adding unnecessary processing to EVERY HTTP/HTTPS call to your web server because now the rules have to be processed for every request. If you could build this into your httpd.conf file instead then the overhead is nearly non-existent.
TL;DR;
No need to re-invent the wheel by adding a lump around the perimeter.

CodeIgniter .htaccess links

I am new to codeIgniter and .htaccess stuff.
I already made to remove the index.php to localhost/ci/index.php/site/home.
So my home page can access now to localhost/ci or localhost/ci/site/home.
I have
Home and About
I can access Home and About if I Am on this link localhost/ci/site/home.
But once I'm on localhost/ci the problem exists because when I click to About the site is redirecting me to localhost/ci/about instead of localhost/ci/site/about. I change the links to Home and About the browser keeps adding the /site every click like
localhost/ci/site/site/site/site/site/site/home
Anyone can help me to fix the problem?
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci
#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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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>
# 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
Have you looked at the URL Helper? It has many functions which will help in these situations.
First make sure you load the helper either in your Controller or autoload configuration.
anchor()
The anchor() helper would be ideal in this instance. e.g.
<?php echo anchor('home', 'Home'); ?>
base_url()
Or alternatively you could build up the href using base_url as previously mention.
About
Go to your config file and set index_page to be empty.
This will remove the index.php
and when you write links set / infront as :
Home and About
what #Svetlio said + i advise you to use site_url() when creating links
You're re-adding the main controller even though the htaccess is set to see that as the base. Writing your links as follows should fix the issue.
About
The other way around it is to run off the base at all times, which isn't really necessary but can work if you're having issues otherwise.
About
What that is going to do is echo out whatever you have set as the base URL in your config every time you write a link so if your base_url in your config is www.localhost.com the above will write www.localhost.com/about.
Don't worry you'll get the hang of it, the routing is probably the most complicated part of CI when you first start.
Home
About

Site developed in Codeigniter only loads home page

I'm trying to move a site developed in Codeigniter from one host to another. The only difference between hosts is that the server the site is moving from is a Windows server (with PHP etc. installed) and the new server is Linux.
However, when I uploaded the site, and changed all the url references, the site only loads the home page.
The address of the new site is http://pioneer.xssl.net/~admin341/
There is a htaccess file, which reads as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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]
# 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
The lines in config.php that relate to the url are:
$config['base_url'] = "http://pioneer.xssl.net/~admin341/index.php/";
$config['index_page'] = "";
Plus the developer (my predecessor) coded a url helper file:
function base_url($includeIndexPHP = true)
{
if($includeIndexPHP)
{
$CI =& get_instance();
return $CI->config->slash_item('base_url');
}
else
{
return 'http://pioneer.xssl.net/~admin341/';
}
}
Any ideas would be appreciated. Thanks.
You may well need to change the $config['uri_protocol'] around to get it working on your live site. This is often the cause of the "homepage only" routing issue in CodeIgniter.
The most common is REQUEST_URI but sometimes PATH_INFO works better.

Symfony: Options for admin URL

In development mode my symfony admin/backend app can be accessed at http://localhost/backend_dev.php. For production mode, I created a controller php file, admin.php, so now in production the admin application can be accessed at http://www.domain.com/admin.php.
What do I have to do to allow the admin app to be accessed at domain.com/admin or admin.domain.com?
Thanks!
you can open new subdomain an on that subdomain (admin.domain.com) setup virtual host that points to server with your symfony app.
you can look at the full tutorial [here][1].
[1]: http://blog.mirthlab.com/2008/03/04/dynamically-loading-symfony-applications-via-subdomains/ here
You probably are better off putting everything admin like in the admin directory, but you can cheat by using mod_rewrite
RewriteRule ^admin/?$ admin.php [L]
Here are some basic ways you could do it:
Either dump admin.php into a folder called 'admin' in the root of www.domain.com, and rename admin.php to index.php. (Easiest solution)
Of course, this way you have to adjust all relative links in admin.php to one level up (appending '../' to the start of all relative urls should work), as well as all absolute links to reflect the changes.
Regarding your admin.domain.com, you should contact your webhost/domain name provider to setup a subdomain for you.
Or if your webhost allows .htaccess files, you could write a mod_rewrite rule.
i would create a module called admin...then in presumably the index action I would put whatever you had in your admin.php file.
then in your routing.yml file just point yourdomain.com/admin to the admin/index....that way you keep everything within the symfony front controller
Andrew
Make sure your DNS resolves the admin.domain.com correctly, then edit .htaccess in the /web to have mod_rewrite pick up on your subdomain and rewrite requests to admin.php. Optionally rename your admin.php to something less obvious or perhaps do a quick subdomain check inside it as well, or extend the rewrite with a 301 redirect if anyone hits domain.com/admin.php.
The following simple .htaccess works for me:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# The admin subdomain returns the backend
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^admin\.domain\..*
RewriteRule ^(.*)$ admin.php [QSA,L]
# Check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# No?, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Change domain to your own domain.

CodeIgniter configuration with mod_rewrite, xampp and windows

I'm a noob to CodeIgniter and am trying to figure out the configuration for an app I'm building. Something is wrong with my setup.
I'm running XAMPP on Windows and am using an alias directory to point to the applications directory. In other words: "http://localhost/app_name/ " points to the root directory of the application. It all seems to work well until I do the .htaccess for mod_rewrite. Then every time I try to go to a controller I get pitched back to the xampp root.
My config is:
Directories
/app_root
/app_root/codeigniter // where code igniter is located.
/app_root/main // where the main app is located. It' the applications
// directory cut from code igniter and renamed.
.htaccess
<IfModule mod_rewrite.**so**>
RewriteEngine On
RewriteBase **/app_name/**
RewriteCond %{REQUEST_URI} ^codeigniter.*
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>
index.php
$system_folder = "#codeigniter";
$application_folder = "main";
app_name/main/config/config.php
$config['base_url'] = "http://localhost/app_name/";
$config['index_page'] = "";
app_name/main/config/routes.php
$route['default_controller'] = "welcome";
I should also state that the app_name directory is an alias for a different drive than the apache root.
Apache Root: c:\xampp\htdocs\
App_name: d:\projects\app_name\development\
The alias is:
Alias /app_name "d:/projects/app name/development"
<Directory "d:/projects/app name/development">
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Thanks in advance for the help... And if you don't mind please "explain" what you're doing when you answer with code. I want to know what I'm doing wrong. If you can help me with this I'll buy you a beer (via PayPal). This is frustrating.
Success!!
I finally managed to get URL rewrite working and what a long arduous journey it was. Here is what I got working finally. Take note that there is no backslash on the RewriteBase. Very interesting given what I've read. Thanks to everybody who tried to help.
# Options
Options -Multiviews
Options +FollowSymLinks
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /app_name
#Removes access to CodeIgniter 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
#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
If your using XAMPP on a local machine, your should use internal rather than mod_rewrite.
It will load your pages under the alias name.
it took me a while to figure that out - apparently you should use mod_rewrite on remote servers to achieve the same thing.
RewriteBase /
in your .htaccess should be
RewriteBase /app_name/
to specify which directory it is..
First, a question. Is your $system_folder variable really set to:
$system_folder = "#codeigniter";
or was that a nerf from the weird (to me) way SO uses markdown? If it is, remove the #. It is an invalid character for directory/file names.
Next, I believe your RewriteBase should be /, since you use an alias in Apache, but don't quote me on that.
I personally use the .htaccess format supplied here: CodeIgniter URLs in the User Guide; under the heading Removing the index.php file. There are many ways to do it, however. A quick Google search yields a couple thousand.
Do you have mod_rewrite enabled? Check the forum post here.

Categories