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.
Related
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
I have installed laravel in my root of domain, its working fine. However
I want use one sub directory for other purpose like install admin panel in it. For example I have installed laravel in example.com Now I want install other core PHP admin panel in new sub directory called adminpanel. its like this example.com/adminpanel/
but when I try to access it, its giving me error called page does not redirect correctly. I have read somewhere that I can achieve it if I modify my .httaccess file but I have not much knowlede of it. Let me know if someone can help me for same.
Thanks!
Better option is creating an subdomain for the admin dashboard. Login into your cPanel and create a sub domain adminpanel.example.com set the path to your new folder.
Non cPanal
If you don't have cPanel, You should create vhosts for your subdomain in server config (apache/nginx).
If my root website www folder is /
and the subdomain folder is /subdomain
I can either get to the the address using one of the following
http://subdomain.website.com/
http://www.website.com/subdomain
Now if I access the site using the http://subdomain.website.com, The codeigniter treats the base_url() as http://subdomain.website.com/subdomain is there away of stripping the subdomin from the end if the subdomain segment has the same name?
I could strip it on a case by case basis, but I'm hoping there is a way to do this using one of the system configuration files.
Whatever you are asking, has something to do with setting up dynamic base url in codeigniter. They have been answered here and also here.
Hope you find it helpfull.
UPDATE
If I browse url like
localhost/myapp/index.php/about_us/index
it works. What is this index.php in url? Do I need to mention it in some config file so that it gets appended and forms correct url in menu/links on site?
Original Question
I have no knowledge of PHP but I got a project which in php (codeigniter) to convert in Ruby on Rails.
I could set up db and application well, when I browse application with base url(without mentioning controller & action) it loads page properly. But as soon as I mention url like
localhost/myapp/home/index
it shows message
The requested URL was not found on this server.
If I change default controller to anything in routes.php that page with index method works fine but not with explicit mentioning controller and action.
I am not sure what is the issue, I don't know how routing works in php :(
Any help will be appreciated.
In CodeIgniter, all requests are directed through the index.php file, which acts like a front controller.
index.php must be present in the URL unless you have created a solution to eliminate it. When using Apache, that is typically done with an .htaccess file. There are hundreds of articles and questions regarding this technique -- certainly you can find something to help you.
In regards to URLs and a config option for defining index.php, CodeIgniter URL helper functions such as site_url() utilize the config setting $config['index_page'] found in application/config/config.php. If you remove index.php from your URLs using an .htaccess solution, you can make this setting blank:
$config['index_page'] = '';
This setting is useful for when you want to rename index.php to something else, as well (not very common).
It seems that you had not configured your web server properly. See this question for details for Apache: routing problem in codeigniter
And here are rules for nginx: http://wiki.nginx.org/Codeigniter
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.