I got a folder called roundcube and also a subdomain called webmail.domain.org. I add this code in .htaccess to block accesing to domain.org/roundcube and allow only on webmail.domain.org.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^webmail\.domain\.org$ [NC]
RewriteRule ^roundcube/$ http://webmail.domain.org [L,NC,R=301]`
Accesing domain.org/roundcube still works and webmail.domain.org gives me this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, me#domain.org and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
What I'm doing wrong?
Related
I have been trying to piece together my .htaccess file, I have not found a lot of information about what I am trying to accomplish or if I am over thinking it.
I am using the following to disable directory browsing it works but I would like to redirect it to a custom 404 error page I have created.
# Disable Directory Browsing
Options All -Indexes
Deny access to directories or files I am using the following
####
# Deny access to certain directories that SHOULD NOT be exposed.
####
RewriteRule ^error/ - [L,R=403]
RewriteRule ^assets/ - [L,R=403]
RewriteRule ^plugins/ - [L,R=403]
RewriteRule ^libraries/ - [L,R=403]
RewriteRule ^includes/ - [L,R=403]
RewriteRule ^bootstrap.php - [L,R=404]
all of these work as it should but I want to redirect to a custom error page in my script folder
example.com/errors/
All i have found is this
ErrorDocument 404 /errors/error-404.html
but have been unsuccessful in getting any of the errors redirected to the one I created.
Without seeing the actual response you are seeing or your full .htaccess file, my guess would be that you are blocking access to the /errors directory that contains your custom error documents. The error documents themselves need to be publicly accessible (although there are tricks you can employ to block access and serve an appropriate HTTP status code).
If you block access to the error document then Apache will fallback to the default Apache response with an additional message along the lines of:
Additionally, a "4xx/5xx error" error was encountered while trying to use an ErrorDocument to handle the request.
I have an Elastic Beanstalk currently working, with her database. The deploy works with any problem. But, my links don't work, so I updated the httpd.conf adding this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
And with this it works.
The problem is that due to auto-scaling, every day httpd.conf is restored, so I lose my config, and need to do it again.
I created a config file inside .ebextensions folder:
container_commands:
01_setup_apache:
command: "cp .ebextensions/httpd.conf /etc/httpd/conf/httpd.conf"
But when i try to deploy, my console shows this:
2019-04-17 11:27:59 ERROR Service:AmazonCloudFormation, Message:Stack named 'awseb-e-vhgv2femtx-stack' aborted operation. Current state: 'UPDATE_ROLLBACK_IN_PROGRESS' Reason: The following resource(s) failed to update: [AWSEBAutoScalingGroup].
2019-04-17 11:27:59 ERROR Updating Auto Scaling group named: awseb-e-vhgv2femtx-stack-AWSEBAutoScalingGroup-14XUH5Q77OR6A failed Reason: Template error: DBInstance aa2jl0t4ovd7y8 doesn't exist
2019-04-17 11:27:59 ERROR Failed to deploy application.
But of course it exists.
Someone can help me? I'm totally stucked on this
Thanks
I know this might be a duplicate, but I have better details.
I have the .htaccess file set to display a custom error page for the most common errors:
# remove .php
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
#Add custom error pages
ErrorDocument 404 /errors/404
ErrorDocument 403 /errors/403
ErrorDocument 500 /errors/500
When I purposely trigger an error 500 it just gives me the default Apache page for that and also says: Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I can access the error page by typing localhost/errors/500 so it's not a problem with the permissions. I searched many forums but haven't found a solution.
Edit: The error 500 was triggered from a malformed request by the rewrite engine. If you type example.com/index/ it tried to go to /index/.php and that caused error 500.
A 500 Internal Server Error is a very general error. It indicates that the server encountered a serious error and is simply unable to process the request as normal.
Many of these 500 errors simply cannot be caught with a custom error document defined "late" in .htaccess.
You stand a better chance if the ErrorDocument is defined in the server config. But even that will not be soon enough for some errors.
However, having said that...
...and also says: Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. I can access the error page by typing localhost/errors/500 so its not with the permissions.
Edit: The error 500 was triggered from a malformed request by the rewrite engine. If you type example.com/index/ it tried to go to /index/.php and that caused error 500
It does appear to be trying to serve a custom (500) error document, but this is also encountering a 500 error.
Specifically, requesting /index/ results in a rewrite loop, ie. /index/.php to /index/.php.php to /index/.php.php.php etc. It's when the server reaches the limit for internal redirects (default 10) does it trigger a 500 error.
Yes, I see this as well for rewrite loops. Even though the error does not appear to interfere with the serving of the ErrorDocument; the message seems to suggest that it does. Requesting the error document directly is OK.
I wonder (purely hypothetical)... since the "internal redirects" limit has been reached in this request (because of the rewrite loop), the ErrorDocument (that is also served by an internal redirect) can't be served because this limit has already been reached!? So this then triggers a 500 error for the same reason! Strictly speaking, the ErrorDocument is served via an internal subrequest (not an internal redirect), although the Apache documentation for the LimitInternalRecursion directive seems to group "internal redirects" and "subrequests" together.
I can't just think of another way of triggering a 500 error, other than triggering it in code (as below - which works OK). Any (fatal) parse errors in the code trigger a 500 error on every request.
RewriteRule ^foo$ - [R=500]
The above should serve your custom 500 ErrorDocument as normal, the ErrorDocument itself is OK.
I have same problem :
url rewriting gives "object not found" error
but I'm using sub-domain and it doesn't work ...
My Original URL :
Http://wiki.example.com/articles/index.php?user=Martin&pass=Cohle
I've placed htaccess file in
"wiki.example.com/htdocs/articles/";
RewriteRule
RewriteEngine On
RewriteRule ^wiki_article/([0-9]+)/([A-Za-z0-9-\+]+)/?$ index.php?user=$1&pass=$2[L]
new url
wiki.example.com/wiki_article/Martin/Cohle/
I get :
Object not found!
The requested URL was not found on this server. If you entered the URL
manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
What I did wrong ?
I wrote a code to redirect people who ask for foo.html to the page bar.html instead.
my .htaccess file is as below
RewriteEngine on
RewriteRule ^foo.html$ bar.html
It works on localhost.But gets the following error when runs in web server.
HTTP Error 404.0 - Not Found The resource you are looking for has been
removed, had its name changed, or is temporarily unavailable.