Apache forbidden error. But the index page works well - php

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

Related

Error 404 while opening site, httpd.conf?

I have a php application that I needed to open on a local web server. I'm running Windows 7 on my VM. Have installed php 7.3.6, mysql, apache 2.4.
After some configuration trying to open my "application" with "localhost/application".
Getting "Internal error 500".
In Apache logs can see "C:/WebData/application/.htaccess: Invalid command 'order', perhaps misspelled or defined by a module not included in the server configuration"
In .htaccess I have:
order deny,allow
RewriteEngine On
RewriteBase /
RewriteRule .* index.php?url=$0 [QSA,L]
Change first line into "Require all granted"
Trying to open "localhost/application"
Getting the error "404 URL /index.php" not found
Trying to open "localhost/application/index.php"
Forwarding to "localhost/ru/main"
Getting another error "404 URL .." not found
Also after each request I see that htaccess is changing back into its initial state with "order deny,allow".
Is there something wrong with httpd.conf?
You probably don't run mod_access_compat, which means Order is not available, as it's deprecated in Apache 2.4 (see https://httpd.apache.org/docs/2.4/howto/access.html)
Now, the reason why your .htaccess files get overwritten probably lies in the PHP code you're running. Some applications try to auto-configure themselves and will write their own .htaccess file to make sure they run properly.
The fact this particular app tries to write deprecated commands without checking if the version of Apache you are running is capable of handling them is concerning and probably means it's outdated.
Do a global search on the application files and look for that Order deny, allow rule, I'm pretty sure you'll find the culprit.
If you can run a newer version of that code, do so, and if not, and if patching it manually is an option, change it to Require all granted

HTTP Error 404. The requested resource is not found when try to open a php file

Am trying to use php I downloaded XAMPP control panel v3.2.2set the port to listen at 8080 and I set the localhost to 8080 too and apache starts and runs fine.
The problem is that for any php file that I try to open by writing at my browser:localhost/thefile'sname.php, even though I have saved it in C:\xampp\htdocs, I get the error:HTTP Error 404. The requested resource is not found. Any ideas as to what could be causing this error to occur and how to fix it?
If it can't find the document it's most definitely with your apache config and your document root or possibly a .htaccess file in the document root?
check or post your apache config and check for .htaccess file.
ah also localhost will only map to port 80, http://localhost:8080/yourfile.php

403 Forbidden : You don't have permission to access

Forbidden
You don't have permission to access /install/step3.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Why is it showing this error when I'm trying to install a script?
Your question have 2 configuration problem.
File Permission (in Filesystem)
ErrorDocument Attribute (in Apache Webserver)
First, You can solve permission error using 'chmod' and 'chown' command.
try this:
chmod -R 777 directory (777 means allow permission for all)
chown -R [user]:[group] directory (generally, the same [user] and [group])
Second, ErrorDocument handle error can occured from invaild ErrorDocument attribute setting in .htacess or httpd.conf(or apache2.conf) file.
try this:
check your .htacess file in 'install/' directory. If you can not check this file, you can try 'ls -al' command in terminal. you have to find 'ErrorDocument' attribute, and remove or correct it.
check your apache webserver configuration file (httpd.conf or apache2.conf). If you can check 'ErrorDocument' attribute, you can try remove this attribute in file. It is temporary, so you must backup it before try suggested cases.
If you can not solve by case 1 and 2, you can try disable 'AllowOverride' attribute. Try find 'AllowOverride x' attribute and replace to 'AllowOverride None'. Because, this problem can have possiblity from .htacess file in parent directories. AllowOverride attribute can control allow or deny additional configuration in .htacess file.
You must restart apache service after try this cases. you can try 'service httpd restart' or 'service apache2 restart' command.
Good luck to your web server and you.
First thing to do is check that the index.html is written in properly. Forbidden 403 usually indicates that the server is running but that the requested resource is not being found.
Then clear your cache. Additionally check your php.ini file to configure any necessary items to get your website running.
The Web server (running the Web site) thinks that the HTTP data stream sent by the client (e.g. your Web browser or our CheckUpDown
robot) was correct, but access to the resource identified by the URL
is forbidden for some reason.
This indicates a fundamental access problem, which may be difficult to
resolve because the HTTP protocol allows the Web server to give this
response without providing any reason at all. So the 403 error is
equivalent to a blanket 'NO' by the Web server - with no further
discussion allowed.
By far the most common reason for this error is that directory
browsing is forbidden for the Web site. Most Web sites want you to
navigate using the URLs in the Web pages for that site. They do not
often allow you to browse the file directory structure of the site.
For example try the following URL (then hit the 'Back' button in your
browser to return to this page):
http://www.checkupdown.com/accounts/grpb/B1394343/
This URL should fail with a 403 error saying "Forbidden: You don't
have permission to access /accounts/grpb/B1394343/ on this server".
This is because our CheckUpDown Web site deliberately does not want
you to browse directories - you have to navigate from one specific Web
page to another using the hyperlinks in those Web pages. This is true
for most Web sites on the Internet - their Web server has "Allow
directory browsing" set OFF.
I have faced this problem. On local host it was running as I want, but when deployed (using Filezilla in my case) on the remote server, the problem occurred. with error 403 instead of 404. I think as mentioned before, It is a restricted access from the server. I only reuploaded the whole folder and every thing is perfect now.
Thanks to this community.
.htaccess
ErrorDocument 404 /index.php
ErrorDocument 403 /index.php
ErrorDocument 403.14 /index.php
ErrorDocument 500 /index.php

How do you modify the apache 403 error displayed when a directory is forbidden

Say you deny access to certain folders or files and you want to serve your custom error messages instead of something like this
You don't have permission to access /classes/classname.php on this server.
Apache/2.2.22 (Ubuntu) Server at webdev Port 8080.
Look into Apache configuration - specifically, ErrorDocument.
You'll add a line to your .htaccess file that looks like this:
ErrorDocument 403 /errors/forbidden.html

404 errors with Codeigniter on nginx when accessing controller

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.

Categories