PIP framework, Not found error - php

My PIP PHP framework was doing fine, then I messed something up: I don't know what it is. Basically for every controller except my default, I get a 404 not found error. If I change the default to a different page, the new page will work fine, but no others will. I can't seem to find any information in the logs.
I'm wondering if there is a good way to trace the route apache is using to find the new page. Or if there are any logs I can check. My local log.txt within the framework shows nothing. Apache log shows nothing. PHP log shows nothing.
I thought it may have something to do with the base_url, but no matter how I change it, my controllers are still not found.
$config['base_url'] = ''; // Base URL including trailing slash (e.g. http://localhost/)
Is there any way to see the absolute path that apache/ my browser is trying to take when I load localhost/controller? Something that would show me file://Applications/MAMP/htdocs/path/to/controller, even if the page doesn't load? Is there somewhere in the config/sys file that I can show that info?
Not sure why it was downgraded. I thought I gave all the information I had about the problem and just looking for how to troubleshoot a 404 not found when my default_controller loads.
Weird! I downloaded a new copy of PIP, copied all the files from my old copy to my new copy, and then now it works. It must have been some directory thing with Apache.

if you have apache running, set the base url to
$config['base_url'] = 'http://localhost/';
// remember the forward slash at the end.
if that still does not do it, go to your MVC framework folder, and replace the index.php and the system folder and all its content, you can take a back up if you want of this folder before you do so,
The there are two files that will mess with the routing
index.php
pip.php
so if your config base url is set as the example above and the controllers are still not found it is one of these two files that have been modified.
// note, you might also want to check the .htaccess file for mod_rewrite which needs to be enabled.

Related

PHP can't file contact.html, but it shouldn't exist? (Smarty Engine)

I've got a legacy PHP project to fix a thing or two. I've downloaded it via FileZilla and served it on my local machine with a local copy of the database. The project is exactly the same with the live one, yet the live one can open the url/contact.html but on my machine it says no such file is found. All other pages go for url/categories/ or url/products/ so I've tried altering the url but no use.
All the other pages within the site are simple: one .php controller one .php model and one .tpl smarty template view. Requiring no .html at all. But this one is somehow different. The .htaccess file is exactly the same as the live version. I've tried adding a rewrite rule to direct every .html to .php but didn't work. I'm lost and out of options, please help? It doesn't even have to be an answer,"Try looking into that" would work too.
I'm working via XAMPP on windows, and I've configured the https:// to http:// on my project but that's all. Even hidden files are checked and confirmed.
have checked that contact.html is a static file (like a real existing html file?)
is there some kind of "routing" within the PHP of the project? If there is route urls might be really anyware.. in the mysql database, redis, a json file and whatnot.. have seen them all.
try to debug where and how it works on the "production" server by using some logging to a file edit the file through filezilla and log to a 'mylog.log' file until you find out what is going on.. or if the site is not used all the time by clients - you can just try to echo stuff to figure out how this exact /contact.html works

How to configure PhpStorm to go through IIS url rewrite when debugging a file rather than loading the file directly

My apologies if this is not possible or if I'm asking the wrong question. I'm a little at a loss for even what to search for here.
I have my website configured so that pages are stored outside the root directory. To do this, all traffic is redirected through a controller.php page using url rewrite in IIS.
So the process looks like this: A user goes to www.mywebsite/account/page.php. No matter where the user went, IIS url rewrite redirects the user to wwwroot/controller.php. Controller.php then grabs the ORIGINAL_URI from an environment variable and then builds the page by including the actual page file from includes/pages/[account/page.php] outside the web root. The path is always the same within the includes/pages/ folder as it would be in wwwroot. If it can't find a matching file there, it instead serves a 404 page.
I have debugging working fine with the chrome plugin by refreshing the page, but I was hoping there was a way to click the debug button within PhpStorm or click one of the browser buttons within PhpStorm and have it smart enough to load the page.
Is there a way to have PhpStorm look at the path of the current file I'm editing (includes/pages/account/page.php) and have it start in wwwroot/account/page.php and go through the url rewrite? Or perhaps is there a way to have it start in wwwroot/controller.php no matter what page I am debugging and pass it the path of the page (possibly in an environment variable)?

PHP: Redirect 404 errors below specific folder

I am working on a already existing intranet. I have build an application and would like to take care of the 404 errors.
The problem I have is that this error management should only have effects on the pages located below the folder I'm working on.
Explications:
My file explorer looks like this:
root
aFolder
anotherFolder
RootOfMyApplication
myPages
I want to redirect all 404 errors below RootOfMyApplication to a specific page using PHP.
For example, browsing to "..../anotherFolder/RootOfMyApplication/notExist.php " should redirect me to my custom page, but browsing to "..../anotherFolder/notExist.php " should'nt.
If possible, I would like to make it so that directory browsing follow the same rule: if the url links to a folder and is below RootOfMyApplication, I redirect to the page.
The problem comes from the fact that I don't manage the root directory, and if possible want to have no impact on navigation outside my folder.
EDIT
What I want to do is the same as a .htaccess file: when an error is thrown, I want to take care of it myself, with PHP. My question is : "Can I do it, and if yes, how do I do it?". I don't want to use configuration files.
"It's not possible" will be accepted as an answer if there is a good explanation.
The Error Handling of files which are not found is a job of the Webserver (in your case Apache).
PHP can't help you because you always have to request one file which is then executed by PHP.
If you are going to request a file which doesn't exist, it can't be executed and the Webserver has do deal with the error. (PHP won't be started.)
But maybe there is a workaround:
If you use URL-Rewriting on your server/ application, there could be a way, but we would need some more Information/ code.
Can't you create an .htaccess in your root directory and change the error documents for your folder?
Talk to the admin and tell him he should change the error documents for your folder in httpd.conf.
(2./ 3. Maybe not an allowed solution for you, because you don't want do use configurations files.)

MediaWiki security: Alternate file ayout

The default file layout of MediaWiki seems quite insecure and good apps expose a single directory (and not the entire hierarchy) to http requests. I've tried to follow instructions found on: https://www.mediawiki.org/wiki/Manual:Security#Alternate_file_layout
And created a /web directory under the base installation directory /wiki and in it created two new files /wiki/web/index.php that looks like
<?php
chdir('../');
require_once 'index.php';
A similar /weiki/web/load.php was created. I've also added a soft link to the resources directory so /wiki/web/resource is actually /wiki/resources
The first request on the wiki (after restarting the server and setting the document root to /wiki/web instead of /wiki) does respond and shows the page well. However, subsequent responses produce a blank page with code 200 (success). Nothing comes up in the PHP error log either. As this happens after subsequent restarts I suspect some caching mechanism isn't working properly.
Any ideas on how to find the cause of the problem?
That chdir('../'); doesn't sound right. You should use an absolute path as demonstrated in the manual you linked, apparently in your case chdir('/wiki/web/');
However, before going through such adventures, I hope you protected the actually sensitive paths like configuration files, uploads and cache... (See the manuals for the setup of those.)

Drupal move from subdirectory

I had a drupal site completely working at www.example.com/example. I copied the files to the root folder in attempt to simply have the site held at www.example.com yet now it is asking for a new install and I have no idea why, I expected to have to make some changes, but not to be confronted with the request of a new install. I have heard it may be something to do with changing the base url but I'm not sure. Can someone please help me?
Thanks heaps
Assuming your site is on a linux based hosting, most probably your problem is divided into two parts
Problem 1) The settings file "sites/default/settings.php" is read only so when you moved the site to another directory it most probably didn't move this file because it is read only, and that was pointed out by another person
Problem 2) The second problem may be the result of enabling clean urls and not moving .htaccess file; when you moved the site to another directory you may have left out the ".htaccess". Check to see if it is moved to the new directory.
Another possibility is that you have a modified .htaccess to make the subdirectory work, in that case you may want to get a fresh ".htaccess" file from here :
http://code.google.com/p/drupalgooglecode/source/browse/trunk/.htaccess

Categories