Why is a rewrite to "/error" invalid? - .htaccess

I experienced a very weird phenomenon! I use an url that is set up like /err/?e=404 for error pages. I also reference them as an ErrorDocument in .htaccess.
I only chose the short version "err", because "error" causes issues! By simply changing "err" to "error", it ceases to work anymore! I get an error 403, but not with my error page, but rather the default error page by apache. This however only seems to apply to my main domain I installed the server with. The other domains don't seem to be influenced by this.
I'm currently testing this using Windows and I get this entry in the error log
AH01276: Cannot serve directory C:/xampp/apache/error/: No matching DirectoryIndex (index.php,index.pl,index.cgi,index.asp,index.shtml,index.html,index.htm,default.php,default.pl,default.cgi,default.asp,default.shtml,default.html,default.htm,home.php,home.pl,home.cgi,home.asp,home.shtml,home.html,home.htm) found, and server-generated directory index forbidden by Options directive
Apparently, /error means something very special to apache2.4 itself. What is it? Why am I not allowed to use this path in htaccess?
On my production system I use
Debian 8.3
Apache 2.4
PHP 5.6.14

Related

Missing htaccess file on server?

i've just created a website. It's hosted by GoDaddy and I use cPanel to manage it.
all of my files relating to my website are stored in a public_html folder.
The problem I am having is that I cannot seem to access different pages I have uploaded, I'll show what I mean.
www.website.com --> works fine (defaults to home.html)
www.website.com/About/about.html --> works fine
www.website.com.com/About --> I get the error below:
"You don't have permission to access /About/ on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request."
I would like website.com/About to display about.html.
I think it may be something to do with the .htaccess file? I may of clumsily deleted it at some point.
I have tried to set permissions to 777 on all my public_html files, but I get the same error.
I have tried to locate my htaccess file, but I think its hidden by default. I've tried to find it using a terminal and connecting to my site - also with no success.
Any help to solve this issue would be great cheers!
If /About/ is a directory and these are static HTML files, rename about.html to index.html.
Servers will look for index.html in a directory if nothing else was specified in the URL.

Why won't MAMP let me chage the root folder to something other than default. I get secure connect failed

I have been trying for around a year off and on to use my mac as a development webserver. I keep running into roughly the same problem no matter what platform I use. I've currently installed MAMP however when I set my root directory to my web page I keep getting security issues from whatever browser I'm using. The default root of MAMP works, no problem but when I change it to what I want I get: Secure Connection Failed. Using the MAMP default if there's an http prefix it's just http but when I set my own root the prefix is https://. The "Problem Loading Page" page doesn't give me an option to add a security exception. This is beyond my pitiful brain level to figure out, so I'm hoping much smarter people than me can help me understand what's going on. I guess I could just move my web site to the MAMP default folder but that seems like cheating...
I figured it out, finally. I kept changing the Document Root to directories leading up to httpdocs. Each worked when loading the page until I arrived at the httpdocs directory, at which time I got the security exception and problem loading page. I removed this redirect from .htaccess in htttpdocs -
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This fixed the security exception.

404 Redirect Error with .htaccess

I'm running a website on a local server (using WAMP Server) and I'm trying to test to see if my 404 page would work, but when I try to navigate to a nonexistent page, I get an error that says:
The requested URL /dsf/sdkmf was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
My 404 page is in the root folder with all my other pages and my .htaccess Error Document handle is listed as:
ErrorDocument 404 /404.html
I don't know why it's throwing me this error much less how to fix it, does it have something to do with my WAMPServer configuration?
Never mind - I figured out how to solve it on my own - apparently you have to use the direct path to the file - even if it's in the root directory of the site itself!

Custom 404 error redirect not working for https requests in htaccess file

I have a simple 404 redirect in a .htaccess file which works fine for Http requests:-
ErrorDocument 404 /apps/handle_error.php
The handle_error.php returns an appropriate PNG image depending on the URL path. However, when I replace the request with Https, it returns the default 404 error page and never does the redirect.
I know my SSL certificate is installed correctly as I get valid content returned for normal static pages. Is there something I am missing in my htaccess file regarding 404 error redirects for Https requests?
(A similar question was asked here but with no clear resolution)
After much soul searching I found the answer, for my specific case anyway.
My Apache2, mod_ssl and mod_rewrite was not configured correctly to work together. The default AllowOverride setting in my SSL config was set to "None" and mod_rewrite requires a minimum of AllowOverride of "FileInfo".
(To be fair, I got my answer from ServerFault)

Enable mod_rewrite rules for page not managed by Joomla - 403 forbidden

I have a simple issue to resolve. Every time I access one of the URLs explicitly defined in .htaccess (used by Joomla), I'm getting 403 Forbidden message.
Details about my setup:
I'm using shared hosting
Joomla is installed in the root folder
my newly created page is located in /new/products.php
.htaccess is the default one supplied by Joomla with one additional rule: rewriterule $/new/products^ /new/products.php [R=301,L]
Options +FollowSymLinks is commented out, but switching it on doesn't change anything
Each time I access mysite.com/new/products I' getting:
Forbidden
You don't have permission to access /new/products/ on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Any ideas?
In the end I simply removed old site, cleared all Jooml entries in .htaccess and did RewriteBase to point to my directory. The problem is no more.

Resources