I'm using Codeigniter for my website, the root website works just fine which has a landing page, however I have a development section located /var/www/domain.com/www/dev/ which /var/www/domain.com/www/ is the root (landing page is stored there).
Now, when I go to domain.com/dev, my codeigniter website works fine, but when I load an controller, e.g. domain.com/index.php/search it gives me an 404 error.
In the error logs of domain.com it shows this:
2011/10/02 02:03:37 [error] 17042#0: *568 open() "/var/www/domain.com/www/dev/index.php/search" failed (20: Not a directory), client: xx.xx.xx.xx, server: domain.com, request: "GET /dev/$
Now I have no complete idea why it's doing this and how to resolve this issue. How can I stop this and also remove the "index.php" remove the URL because Codeigniter tutorials only contain apache's rewriterule which isn't valid on nginx.
I believe that codeigniter uses the front-controller pattern, which will redirect all requests to index.php using a rewrite rule.
As the rewrite rules are for apache and not nginx, the server is actually looking for a directory called search which lives under another directory called index.php and so on.
I don't have much experience when it comes to nginx, but I believe this blog post can help you come up with rewrite rules on nginx.
Related
Hei guys,
for my webpage I wanted to implement some simple REST-Services to serve some Json.
To achieve that I created subfolder api and in this folder I created index.php and .htaccess file.
index.php uses AltoRouter to handle Routes called on /api.
.htaccess locks like following:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
mod_rewrite is enable on my webhoster. (I was abelt to test this using some simple examples served by the webhoster)
I tested everthing on my local computer using localhost xampp.
Everthing is working fine. (GET and POST Requests)
After uploading this to my webpage I figured out, that POST Requests are Redirected to GET and therefore are not working.
Can anybody help with that issue. I need this POST Requests to be redirected to my index.php and be handled there to make some data update on my webpage.
Regards
Manuel
There is an update:
My Webhoster seams to use a nginx proxy that redirects to Apache.
POST seams to get coverted to GET and therefore my mechanism is not working anymore.
Can anyone tell me how to force nginx to redirect POST as POST?
Manuel
You can include the PHP file in your /api folder in your PHP file in your Root folder.
Just add the line include "./api/index.php" to your PHP in the Root folder.
Then the functions work in the PHP file in the /api folder, without having to open that specific PHP file in the /api folder.
https://www.php.net/manual/en/function.include.php
I have issue regarding URL in Codeigniter on server.
Actually, Site was working before shared hosting server like http://example.com/login
But after change server dedicated and integrate SSL, the site not working inner pages. Like https://example.com/login where got below issue:
Not Found
The requested URL /login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
But home page open https://example.com It might some issue related rewrite or else. I tried using .htaccess also but nothing changed.
Site page is open using add /index.php in between like https://example.com/index.php/login
Any one have idea or trick to sortout it.
Thanks
Well I have been having a tough time trying to figure out the reason for getting the forbidden error message on my wamp server.
I have a folder website_ink inside c:/wamp/www/ folder. when I access
http://localhost/website_ink/
the index page loads fine. But when i try to access any other page it gives me a forbidden error message.
The url i tried accessing was http://localhost/website_ink/cloud-plans.
This page does exist inside my root directory meaning inside website-ink/cloud-plans.php page does exist.
This is the error I find when visiting the url on browser
Forbidden
You don't have permission to access /website_ink/C:/wamp/www//website_ink/cloud-plans.php on this server.
Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80
This is the error message i found in the log file
The given path is misformatted or contained invalid characters: [client 127.0.0.1:60811] AH00127: Cannot map GET /website_ink/cloud-plans HTTP/1.1 to file.
I do not have any virtual hosts setup or anything fancy. Also I tried upgrading from Apache 2.2 to Apache 2.4. Currently I am using Apache 2.4.
Please help
The reason why it happens is you try to open "/website_ink/cloud-plans" instead "/website_ink/cloud-plans.php".
In case you want to use path wiht out file extension you need add rewrite rule to .htaccess or httpd.conf:
RewriteEngine on
RewriteRule ^/(website_ink/.*)/$ /$1.php [L,QSA]
Also you need mod_rewrite to be installed and enabled
This is most likely completely noob and something simple ive missed but its been driving me mad all day and the IRC is not being very helpful :c
Using Laravel PHP Framework and routing is failing.
Environment:
Host machine Ubuntu 14.04
Guest Machine Laravel - Homestead Vanilla(Standard) Vagrant Box
Project:
Default unedited Composer Laravel Project
Behaviour
Navigate to /public you get the laravel project hello page(suggests friendly urls and routing is working fine). When you navigate to /account you get "No input file specified. "
The Code
-- app/routes.php --
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/account', function()
{
return View::make('account');
});
PLEASE NOTE HERE THAT THE ACCOUNT.PHP WAS CREATED IN THE VIEWS FOLDER
Nginx Error Logs
2014/06/24 06:56:49 [error] 1307#0: *97 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/Code/profile_system/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: profile-system.app, request: "GET /accounts/create HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "profile-system.app"
So apparently the issue is that it cant find index.php in the / of the project. But laravel does not have an index.php in /.
Any ideas? See this link for complete environment info. happy to add anything else on request. https://gist.github.com/Jonjoe/6359e71e47b7a489109c
If you navigate to /public to see Laravel's welcome page then your server is not configured properly. You should be able to get the welcome page without the /public in URL.
Probably the simplest way is to use .htaccess file (placed directly in Laravel directory) with the content:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It is not the best solution though. You should threat your public directory as the website root instead of the Laravel directory. You can read more here.
Posting the answer because if you don't know it will destroy you.
Laraval applications start after /public. Make sure your hosts file / Web server specifies the path to be /root/to/project/laravel-root/public. THEN ITLL WORK :p.
Im going to mark Linek's answer as correct becuase if it was a friendly url issue that is the correct fix.
So, we've got PHP 5.3.2 installed on a Windows 2008 R2 Server. PHP.ini file is loaded, everything looks good on that end. We are also running IIS 7.5 and ISAPI_Rewrite. We have a PHP-based CMS installed and it runs dandy.
The problem lies with posting variables. Example:
We have a contact page: http://example.com/contact with a form that posts the variables on submit via PHP.
But then, when a user submits the form, it seems as if any page with variables POSTed (like this one) end up returning a 500 error.
EDIT I have another idea: Not sure whether it could have to do with the .htaccess files. This server gives 500 errors for, like, everything.
The CMS we're using passes everything through an index.php file, so our .htaccess file takes index.php out of the url so that urls are clean.
RewriteEngine on
RewriteCond $1 !^(images|documents|admin|themes|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
The headers for the posted-to page are as follows:
Request URL:http://domain.com/
Request Method:POST
Status Code:500 Internal Server Error
**Request Headers**
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png;q=0.5
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Content-Type:application/x-www-form-urlencoded
I could be way off here, but is there some sort of regex or setting I missed in IIS that any .php file with post variables is just not assigned to get picked up by PHP?
*EDITS / UPDATES *
I RDC'd into the computer to test, and also turned on Detailed error reporting.
The website, with clean URLs, works fine until submitting a form.
Server error: HTTP Error 500.0 - Internal Server Error
The FastCGI process exceeded configured activity timeout (it took a while)
Handler: PHP5
And then in the logs:
2011-01-12 16:57:56 10.64.181.170 POST /index.php/ - 80 - 10.64.181.170 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1; +WOW64;+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727; +.NET4.0C;+.NET4.0E) 500 0 258 82850
--Steph
I encountered this today on a customer website.
This customer was using UMBRACO as their CMS and had a large web.config file in the root of the site.
My background is in Linux rather than Windows, however after randomly shotgun-removing lines from the web.config, I discovered the problematic line was something like:
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
If you are still having this problem, check to see if you have a web.config in the root of the site with a line similar to this in it. Commenting it out seemed to do the trick, I'm not sure what it is used for.
IIS does not natively support .htaccess files and rewrite rules. To work around that you need to:
Install URL Rewrite for IIS
In IIS manager for your site double-click URL Rewrite
Click Import Rules
Locate your .htaccess file on the disk
Click Import
Review and click Apply
IIS rewrite rules will get saved as web.config XML file. Conversion works out-of-the-box for most rewrite rules.