CakePHP without htaccess and mod_rewrite - how to overwrite WEB URL PATH - php

So I installed CakePHP on a IIS box and followed the steps of uncommenting the appropriate lines in core.php to make my URLs work as index.php/controllername/methodname/
My only problem now is that all the convenience functions such as $html->css, $html->link, etc. are pointing to some wacky paths. If I am viewing index.php/pages/home doing $html->link('Test', '/pages/test') produces a link to index.php/pages/pages/test/
How do I fix this?

I had a similar problem with my plugin paths and I posted a ticket.
Try to insert ../../ at the beginning of the path.
$html->css('../../your_style_sheet');
For the links use this syntax:
$html->link('Test', array('controller'=>'pages', 'action'=>'test'));

Related

PHPStorm and CodeIgniter routing issue

I started studying CodeIgniter Web Framework and I am trying to work with PHPStorm 8.0.3 on Kubuntu 14.04. When I unzip CodeIgniter downloaded archive to root Apache folder /var/www/html and go to
localhost/index.php
then it works okay and I see "Welcome to CodeIgniter!" page. Also I
can use
localhost/index.php/welcome/index
and see the same page as it should be.
When I created a new PHP project in PHPStorm and try
localhost:63342/codeignitor/index.php/
then I see welcome page, but if I use
localhost:63342/codeignitor/index.php/welcome/index
then I get 404 page. Also all my own controllers are not available and
cause 404.
I can call my own controller only if I make it default
$route['default_controller'] = 'mycontroller';
I think that this problem occurs because the URL contains name of my project /codeignitor/, but I'm not sure about it. So I need your advice how to set CodeIgniter environment in PHPStorm correctly to solve this problem. Thank you!
Codeigniter uses the URL to determine routing, therefore /codeigniter/index.php/welcome/index and /index.php/welcome/index are not equal paths. I would recommend using one or the other, and adjusting your /index.php and /config/routes.php to accommodate for your desired path.
References:
Codeigniter Subfolder
https://www.codeigniter.com/user_guide/general/urls.html
https://www.codeigniter.com/user_guide/general/routing.html
https://www.codeigniter.com/user_guide/general/environments.html

Joomla administrator redirects to installation

I have a Joomla 2.5 site were I can no longer access the administrator panel. That only redirects me to /installation/index.php which (as it should) gives a 404. I think this happened after an upgrade.
I tried to clear browser cache as suggested here: Joomla 1.0, administrator link redirect to "installation/index.php", how to prevent this redirection?
But that didn't work.
A long time ago, back in the 1.x days, there were some security advices on the Joomla site which among other things suggested to move configuration.php outside the public_html directory which I followed. I can't find them now, but I tried to copy the configuration.php file to Joomla root directory as well as keeping it at the directory which is defined in defines.php (define('JPATH_CONFIGURATION').
Any ideas?
My extensions
bash-3.2$ find plugins/ -type d
plugins/
plugins/authentication
plugins/authentication/gmail
plugins/authentication/joomla
plugins/authentication/ldap
plugins/captcha
plugins/captcha/recaptcha
plugins/content
plugins/content/emailcloak
plugins/content/finder
plugins/content/geshi
plugins/content/geshi/geshi
plugins/content/geshi/geshi/geshi
plugins/content/joomla
plugins/content/loadmodule
plugins/content/pagebreak
plugins/content/pagenavigation
plugins/content/vote
plugins/editors-xtd
plugins/editors-xtd/article
plugins/editors-xtd/image
plugins/editors-xtd/pagebreak
plugins/editors-xtd/readmore
plugins/editors
plugins/editors/codemirror
plugins/editors/none
plugins/editors/tinymce
plugins/extension
plugins/extension/joomla
plugins/finder
plugins/finder/categories
plugins/finder/contacts
plugins/finder/content
plugins/finder/newsfeeds
plugins/finder/weblinks
plugins/quickicon
plugins/quickicon/extensionupdate
plugins/quickicon/joomlaupdate
plugins/search
plugins/search/categories
plugins/search/contacts
plugins/search/content
plugins/search/newsfeeds
plugins/search/weblinks
plugins/system
plugins/system/cache
plugins/system/debug
plugins/system/highlight
plugins/system/languagecode
plugins/system/languagecode/language
plugins/system/languagecode/language/en-GB
plugins/system/languagefilter
plugins/system/log
plugins/system/logout
plugins/system/p3p
plugins/system/redirect
plugins/system/remember
plugins/system/sef
plugins/user
plugins/user/contactcreator
plugins/user/joomla
plugins/user/profile
plugins/user/profile/fields
plugins/user/profile/profiles
Try this, if wont work move to another point.
1. Change this
if (file_exists(JPATH_INSTALLATION.'/index.php')) {
header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')).'installation/index.php');
To this:
if (file_exists(JPATH_INSTALLATION.'/index.php')) {
header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')).JPATH_INSTALLATION.'/index.php');
Its line 25-26 in administrator/includes/framework.php
2. Remove line 23-32 in this file - it checks for installation folder and size of configuration file, if you dont have installation folder and configuration file is ok, you can remove this
3. set variables $sef and $sef_rewrite to zero in configuration.php
Diagnosing The Situation
Perhaps you should start with diagnosing the plugins? By removing them all and adding in one by one to see what one causes an issue. As you recently updated, a plugin perhaps is causing this issue as it is outdated and is creating conflictions between the software and the extension.
The issue may be based around that the configuration cannot be found, so Joomla presumes you have not installed the software.
Have you done all of these?
Removed installation folder
Checked if .htaccess isn't causing the issue
Attempt a downgrade and upgrade?
I think plugins would not cause redirecting to installation folder. Most likely the system thinks it's not installed yet, which would most likely be caused due to a missing configuration.php file in a location where Joomla expects it to be.
You can try to add something like this to the end of defines.php:
var_dump(file_exists(JPATH_CONFIGURATION.DS.'configuration.php'));
If it outputs true - that means config file exists and the problem is not in it.
Then I would rename .htaccess to htaccess.txt to make sure it has no effect.
If that doesn't work you could also lookup index.php file in public_html folder and make sure no changes have been made to it.
I'm pretty sure config file is not in its location and this should resolve your issue. Hit me back if it doesn't and I will help you further.
Try this things
Delete the joomla installation file directory: c:/host/project path/your site/installation
Check your server and restart it
Be ensure the required services are available on the server
Try installing the new Joomla package http://www.joomla.org/download.html
Thanks
IMHO you need to delete the /installation folder after an installation. Otherwise if it finds this folder and you get redirected there.
For security reasons Joomla does not allow you to be redirected to your site front-end or back-end before you delete the installation folder after the installation is complete.Please make sure the joomla /installation folder is deleted, and if yes, restart your server if possible.

Routing in codeigniter php

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

Magento helloworld tutorial

We're working on Alan Storm's tutorial: Magento Controller Dispatch and Hello World on Magento 1.5.0.0.
at the step:
Clear your config cache, and load the following URL
http://exmaple.com/helloworld/index/index
and it produces a page not found error, as follows:
Whoops, our bad...
The page you requested was not found, and we have a fine guess why.
If you typed the URL directly, please make sure the spelling is correct.
If you clicked on a link to get here, the link is outdated.
Two of us are working on this. One of us on a Linux platform, the second on Mac OS X 10.6.7. The same "page not found" error on both platforms. We both have double-checked each other's tutorial code by comparison to Alan's article. It seems that something is remiss in the tutorial code in that it would not work on two independent platforms.
What is the best way to move ahead with debugging something like this?
First check the module is active, at the very least it should appear in System > Configuration > Advanced > Disable Module's Output or use Alan's Module List.
Next, double check for typos in the controller class and pay particular attention to the case. In the config frontname should be frontName (a capital N is often overlooked).
I had the same problem , Double check your /path/to/magento/app/etc/modules/Module_Name.xml , I had the codePool set to "community" and placed my extension in "local" directory this caused the 404 issue, when I changed the codePool value to "local" everything worked
example.com (or exmaple.com as typo'd in the tutorial) is a placeholder link used in documents. You are supposed to replace it with your own hostname, i.e. if you are developing on a local webserver http://localhost/, like this: http://localhost/helloworld/index/index
Just stumbled over the same problem and found the solution to be that mod_rewrite has to be enabled on the server for the URL given in the tutorial to work. Elsewise, it will work with the following URL as well:
http://exmaple.com/index.php/helloworld/index/index
try by adding "index.php" in your url.
For example: http://example.com/index.php/helloworld/index/index
If you are done with this. Search some article to remove index.php from magento.
I am on magento 1.8 and i fixed my 404 error by doing the following. inside Magentotutorial_Helloworld.xml they tell you to put this code in "local" since i do not have a local folder i put mine into the community folder. Change the code to this and it will work. "community"

zend framework problem with paths

I have installed zend framework on my local machine. I have configured a vhost in httpd.conf and have added a line in my hosts file (127.0.0.1 mysite). I am running windows 7. Everything works perfect. The problem is when i upload on a hosting server the paths get mixed up.
I am uploading on a remote dir called zf-framework. To access the index page i need to type this url: http://mysite/zf-framework/public. It displays the index page but when i press any links on the page they get mixed up and end up being something like http://mysite/controller/action when in fact it should be http://mysite/zf-framework/public/controller/action. I have found a work-around for this situation...to use echo $this->baseUrl(link) for any links i have in the layout.phtml. The problem is more serious when it comes to submitting forms. I can't use baseUrl there....or i don't know how to use it. Is there a way to write some general config stuff so that this could be automatically resolved by the framework. Let's say to write something in index.php or bootstrap.php that will fix the paths automatically?
If you're using Zend_Application, then add the following to your configs/application.ini file.
resources.frontController.baseUrl = "/your-path-here"
If you're not using Zend_Application, then do this in your bootstrap, or index.php file.
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/your-path-here');
You won't have to use $this->baseUrl() when submitting a form to the same action and controller (just leave out the action attribute in the form tag), or when using the Redirector action helper. However, links in your view scripts will require you to $this->baseUrl('/url-without-base'), which doesn't seem too bad to me.
I am not 100% on this, but if you specify the route in your routes.ini as zf-framework/public/Controller/Action etc this should fix your issue.
I would see this as a bandaid, but I am not 100% sure on how to properly fix your issue other then you modifying the vhosts file on the remote server to set a document root to the public folder. If that is not an option, well the above should work, but know that all of your files are potentially accessible from everyone (at least your folder structure). I am not sure what harm this can do (if any) other then if your database schema is in the /data directory.
It is better to try and get the public set as the web root, if possible.

Categories