Hey everybody, Im really confused about this problem. Ill try to describe it:
The problem is:
http://mydomain.com/somedir/somephp.php?arg1=value&arg2=http://otherdomain.com&arg3=http://othertoo.com/somepath/something... totally fails. With and without url encode.
My site reads in everything after mydomain.com/everything, except files and directories which are exists. I'm doing it with mod_rewrite:
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ handler.php
The query example above is landing at handler.php. If I comment out the RewriteRule, there will be an apache error:
Forbidden
You don't have permission to access /somedir/somephp.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Lots of testing etc, Ive figured out that there is a problem with the http://, or :// string in the url arguments.
But its coming in url encoded :S
This stuff should be an openId authentication system, and its fails at the postback, and I'm sure the url in the url argument makes this error.
I never meet this problem before, altougth, I did a lot of same thing.
The url encode thing must work.
Please help me!
Thanx!
I faced exactly the same problem. here
You will need to contact your hosting service provider. There are some rules that are conflicting with their .htaccess rules. So request them to whitelist your site from such rules.
Don't forget to include a url of the problem while reporting the issue to your webhosting provider.
I am pretty much sure that your problem will be solved once your site has been added to the whitelist of your service provider security rules.
My problem was solved when I reported the issue to my website hosting provider.
You could try encoding it with base64:
http://www.webtoolkit.info/javascript-base64.html
then decode it in the application.
Related
I am try to access another website through my website. And i use .htaccess redirect code to do that but it is not done.
i want to redirect https://web.karlosms.com to http://36.255.3.40:80 without changing the url.
I tried to use this code but it is not working.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^web.karlosms.com
RewriteRule ^(.*) http://36.255.3.40:80/$1 [P]
It show the error:
Forbidden
You don't have permission to access /index.html on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
please Help me on this. Thank you.
You can't rewrite to a remote server.
You'll need to use a proxy directive to achieve that, which is probably not ideal, but the only solution to keep the initial URL.
See https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
Additionally, you'll need to fix what happens on the remote server (you shouldn't end up on a 403, even when redirecting), but why don't you make web.karlosms.com to 36.255.3.40 directly and define the proper virtualhost on this remote server?
It seems like there's no particular port or folder mapping between the 2 so you could deliver everything from the final server. Having a proxy in between is convoluted.
Firstly I apologize if this is slightly broad of a question. I hope it is not.
On my localhost I have this htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/?([a-z]+)/?$ http://myasite.com/region.php?reg=$1 [QSA,L]
RewriteRule ^/?([a-z]{2})/(.*?)/(\d+)$ http://myasite.com/single-id.php?reg=$1&n=$3&area=$2 [L,QSA]
When I go to:
http://myasite.com/uk
I am redirected to:
http://myasite.com/region.php?reg=$1
However the URL stays the same as:
http://myasite.com/uk
Which is PERFECT. However, when I upload that to my site server the url does not retain the clean url.
I have asked the server support guys and on the live chat to which I am convinced they nothing about it. I kept getting the response from them 'The problem is the htaccess, contact a developer'
My server has ControlPanel/WHM
Does anyone know why the clean URLS are not working on the server but they are on my localhost and could someone provide steps to help check/fix this issue?
It may be something to do with your RewriteRule, so modify it to the following:
RewriteRule ^([a-z]+)$ region.php?reg=$1 [QSA,L]
Might also be worth replacing + with the exact character count you may encounter for each region, i.e. {2} :-) - Example
Please echo $_SERVER['SERVER_SOFTWARE']; just in case the server is not running the php file on nginx server. I have seen this one time.
<?php
echo $_SERVER['SERVER_SOFTWARE'];
?>
I used this .htaccess file on my localhost:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
But when I uploaded my site to the ftp, it suddenly doesn't work. I set the base_url. Mod rewrite is enabled. What else can be the problem. My knowledge is very limited, I was already happy, that I programming part, but this server stuff is over my head. But I'm willing to learn it, so if you recommend a place to start, I'm open to that.
So right now only a formatted page comes in, with basic css settings and the 404 message. It's weird, that this message can be created in a form like that, so it means it's not a technical problem, but a settings problem. I googled around, tried more .htaccess files, but nothing works. Thanks for your help!
This is silly. The controllers must be named starting with a big case letter. So the only problem was, that I named my default controller as welcome.php instead of Welcome.php. It was hard to figure out, because it worked on localhost. So this had nothing to do with .htaccess at all. May be valuable to others, so they don't make the same mistake.
I have seen this error when people are using FastCGI - you need to add to the config.php:
$config['uri_protocol'] = "REQUEST_URI";
This clicks everything together - Might not be the answer to this issue but worth a try and others with your symptoms may find this useful.
Thanks,
//P
I have a basic MVC system that is sending POST data to URLs such as
admin/product/add/
But this is giving me an error
Forbidden
You don't have permission to access
/admin/product/add/ on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
The RewriteRule is simply
RewriteRule ^(.*)/$ index.php?uri=$1
Last time I saw this on a server changing file/directory permissions to 755 seemed to fix it but not this time. I have never really understood the reason for the error so was hoping someone may be able to provide some more information?
You have 2 errors:
You don't have permission to access /admin/product/add/ on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
The 2nd one is quite certainly a consequence of the same bug. You may have something in your apache configuration which remove 404 errors from default http server handling and push it to your php application, if this php application was working we would have a nice 404, but...
The first one tells you your php application is not running at all.
So. This first error tell us that apache did try to directly access the directory /path/to/documentroot/admin/product/add/ on your server and to produce a listing of it (well a listing of the directory content would be done only if apache were authorized to do so). But of course this is not a real directory on your server. It is a virtual path in your application. So apache ends up with a 404 (which leads to error 2).
The application handles a virtual path, apache does not manage it. The RewriteRule job is to catch the requested path before apache is trying to serve it and give it to one single php file (index.php) as a query string argument.
So... this rewrite rule was not applied. Things that could prevent this rule to be applied are numerous:
mod_rewrite not activated: is the module present and enabled (RewriteEngine on)?
syntax error: mod rewrite syntax is quite hard to read, sometimes really complex. But here it seems quite simple.
The RewriteRule resulting file is maybe not a valid target for apache. If the index.php file is not present in the DocumentRoot, or not readable by the apache user, then apache will fail. Warning: having a file readable by the apache user means having read rights on the file but also execution rights on all parents directories for the apache user. This is where your classical chmod/chown solutions are fixing the problems.
The rule must be in a valid configuration file. Is this rule in a an apache configuration file, inside a Location or Directory section? Or maybe in the global scope -- this may alter the rewrite Rule syntax--. Or is it in a .htaccess file? If it's a .htacces does apache reads the .htacces files and are mod-rewrite instructions allowed there (AllowOverride None). Isn't there others .htaccess files taking precedence?
So to fix the problem:
If you have an apache version greater than 2.2.16 you can replace the RewriteRule by FallbackRessource /index.php to check that this does not come from a mod-rewrite problem.
try to directly request index.php, so that at least a direct request to this file does work
try to directly access a valid ressource on the documentRoot (a txt file, an image, something that should not be handled by the rewrite but directly served)
check that if any of your virtual paths could map real physical paths Apache is not trying to serve the physical one (like when you write a RewriteCond %{REQUEST_FILENAME}-d) but really push the path to index.php
check apache error logs.
debug mod_rewrite with RewriteLog and RewriteLogLevel
collect facts, settings and tests, and then push that to SO or Servfault.
So the problem is quite simple: the php application is not receiving the request. But there are a very big number of ways to end in this state. The message in itself is not very important. The only way to find the error is to check all parameters (or to have years of bug fixing experience and developing a pre-cognitive intuition organ for lamp bugs -- usually a beard --, like admins). And the only way for us to help you is to find strange facts in a big list of configuration details, this is why good questions contains a lot of informations, even if all theses informations looks simply "classical" for you.
EDIT
To clarify the problem you should edit your answer, track the POSTÂ requests with tools such as Chrome developpers tools or firebug (keep the network tracking in record mode to catch several POSTS) or try to replay the post with Live HTTP headers reply. You should try to isolate the problematic POST and give us details. Debug is not magical.
Now I know one magical random POST failure. It's the empty GET url bug. It could be that (or not). If you have one empty GET url hidden somewhere (<IMG SRC="">, url() in css, or an empty LINK in headers for example. As theses hidden POSTÂ are defined in HTTP as "replay-the-request-which-launched-the-source-page, and some browsers even replay the POST that gives you the page if they found one. This could lead to broken hidden POSTS.
It could be also that the POST is not sent to the right server. Hard to say. So please collect informations from your comments, add some more network analysis and edit the question which is now really containing not enough facts.
Try this:
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^(.*)/$ index.php?uri=$1
Use this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?uri=$1 [L]
Also use only www or non-www domain but not both at the same time. Redirect users with htaccess where you would like like to...
NonWWW to WWW:
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
WWW to NonWWW:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^www\.(.*)$ http://%1/$1 [R=301,L]
I am writing a Facebook app and for it to work properly, I need to set the Site URL inside the Application settings. The problem is that if I set my Site URL to be
domain.com
it works on my system and a bunch of systems that I tested it on. Some of my friends complain that it is not working on their system. When I looked at what the error was, it was sending me back this:
Given URL is not allowed by the Application configuration.
which is telling me that the referrer URI that I am sending it is not what it is expecting in the Application settings. So what I did was I changed the URL to:
www.domain.com
and now my friends are able to use the application and it is failing to load on my end. Does anyone know how to fix this issue? Both cases, I tested it on Windows and Ubuntu with the same browser version yet I am seeing this problem and I don't seem to understand why this is happening.
Ok I am not a fan of this solution myself but consider this a hack... This really should be fixed on Facebook end :(
Step 1: In the Facebook Site-URL field of your application just put www.domain.com
Step 2: Create a .htaccess file in the app directory and put the following text in it:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
Hope that helps someone with the same behavior.