Codeigniter redirect main folders (application, system) - php

I build an application with codeigniter and I wondered if it was possible to redirect access to major folders such as application, system.
Currently, I get the message "Directory access is forbidden." but can we not go redirect to one same controller ? it is not possible to have a controller named "application"?
I use Nginx 1.4.4. Thank you.

Ok you can do it by creating an index.php file in your folder an putting a redirection :
<?php
/**
* Redirect to application index controller
*/
header('Location: ../application/index');
It worked for me.

Related

Redirect to a specific folder -PHP

So I created a register/login system. Once they register, a folder will be created automatically with their username as the folder name(like a personal folder). I want them to be redirected to that folder once they logged in.
Can I use:
header("Location: http://example.com/Parentfolder/theusersfolder);
then replace theuserfolder to redirect the user to his folder? or something that might help?
Instead of creating Folder. You can use dynamic Routing. It will also help you when user renames their username.
If you are using Core PHP these links will help you
How to route Dynamic url in Core php
https://medium.com/the-andela-way/how-to-build-a-basic-server-side-routing-system-in-php-e52e613cf241
Or you can use any PHP framework

Codeigniter how to access views/web pages from third party folders

I am in the process of installing SimpleSAML and in the php library, there is a folder called www that has index.php. According to the docs, there is an admin console within it. However, at the moment I am unable to access it via the url www.website.com/third_party/simplesaml/www/index.php.
I am supposed to use the admin console to generate some metadata so I'm just wondering if it is possible to route to a view from there?
I'm thinking that I create a controller and just hard link $this->load->view('url to www') but I'm not sure if that works.
In controller’s constructor add
include APPPATH . 'third_party/simplesaml/www/index.php';
to include the file in your project.
you can set base path in route file and instead of $this->load->view() you can use renderView() function to access view in codeigniter.

How to get Parameter names in ZF2 site's Index Controller?

Hi currently i am doing project in ZF2. In my project there are lot of folders in public directory. when any of visitor enter www.domain.com/folder-name it should redirect to that folder in public directory. in scenario how can i get that name of the folder name into one variable in site IndexController
Your question is not very clear to me. When you call a sub-folder within /public, then depending on your ReWrite-Rules, you'll either get 403 Forbidden or you'll get the DirectoryIndex. If you call a file, you'll see the file.
Either way, ZF2 isn't even running at that time.
What kind of variable do you want to have in your Controllers and for what purpose? Do you want to create something like a DirectoryListing?

change the url scheme

I am using hmvc for creating a register page :-
In the url now I am typing :- http://localhost/CI/index.php/user/registration
user is the module name
controller :- registration.php
<?php
class Registration extends MX_Controller{
function index() {
$this->load->view('homepage');
}
function register(){
$this->load->view('registrationPage');
}
}
?>
view :- homepage.php
<html>
<body>
register
</body>
</html>
the problem is that in my url i have to type http://localhost/CI/index.php/user/registration/register for coming to registration page.
I want http://localhost/CI/index.php/user/register how can we do this.?
setting base_url is not working and setting routes ia also not working.
Is this possible to go to any page without giving module name in the url..?
Edit you routes.php file under config folder
$route['user/register'] = 'user/registration/register';
You could use url rewrite in .htaccess file
See url rewriting without htaccess
and how to do url-rewriting in PHP
In CodeIgniter, .htaccess is present in
system/application/config/config.php
Get more info here as I am not aware of CodeIgniter
You should create a proper URL for your site by adding an entry in your host file. For example:
127.0.0.1 http://mysitename
or
127.0.0.1 http://localhost.mysitename
Google up how to set a virtual host in apache. You should be able to find plenty of articles about that. Now edit your apache config to enable virtual hosts. With this feature enabled you will create a virtual host entry for your site. The virtual host tells apache to map the URL you've chosen to the specific directory path of your project files. (This way the actual directory path is not part of your URL.)
Next you should edit your .htaccess so that requests are always routed through the index.php front controller. Once this is done you will not have to use '/index.php/' as part of each URL. Read the section in the Code Igniter user guide called Code Igniter URLs. It has sample .htaccess configurations. Moreover, it explains how Code Igniter URLs work.
In order for CI to work with the virtual host, you must set the base URL in your CI config file to match the v-host URL.
Once you've completed all of this, you will need to restart apache.
Now you can just name your controllers and methods in accordance with the URL structure you want. In this case, a controller called user.php with a method called register.
Is it a must to use HMVC in your project? Otherwise go for simple Codeigniter way because that is what you expect in this situation.

how to hide url in cakephp?

I m doing web application in cakephp1.3. I want my Url
http://mydomine.com/cakephp/users/login to be display as http://mydomine.com/users/login.
Where users is controller name and login is action. I dont want to display cakephp on my url. Please help me to fix this bug.
Thanks in advance
Pushpa
You can direct your domain to the cakephp directory... No need to work with rewrite.
either move all the files from the cakephp folder to the / folder,
or use apache rewrite rules to remove cakephp from the request
Put all of the content of your app dir to your web folder and then u will be able to access home page of your project directly. Don't forget to copy .htaccess.

Categories