TYPO3: Bingbot creates an ext_form error which get cached - forms

We have a problem whit one of our TYPO3 installations. The Bingbot which visits the site calls a controller of the old ext_form extension without parameters and creates an error.
207.46.13.XXX - - [16/Oct/2018:00:18:48 +0200] "GET example.html?tx_form_form%5Baction%5D=process HTTP/1.1" 200 10256 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
The problem for us is not that this happens but that TYPO3 is caching the site with "Oops, an error occurred! Code: 20181016001848e0153dcf" as content.
Is there a way to say TYPO3 to not cache the site if an error occorres or to send the bot to the 404 site if he calls the site with false parameters.

There are several things you can do:
exclude the page with the parameters in robots.txt (Edit: After consideration this solution is probably unsuitable for the specific problem)
redirect in .htaccess if the page is called without required parameter, a redirect should be recognized by the bot too.
check why the bot is even calling the page without required parameter, perhaps you can avoid it.
bing can be configured for a specific URL, this page can be a starting point for you.
EDIT:
Example for htaccess (not tested):
RewriteCond %{QUERY_STRING} .+
RewriteRule ^example.html?tx_form_form%5Baction%5D=process$ example.html [L,R=301,QSD]
The target example.html can be anything, either a custom 404 page or just the list-view. The code 301 in [L,R=301,QSD] can be adjusted according to HTTP Status Codes (3xx). If it's redirected to a (custom) 4xx page the HTTP status code should be accordingly (404, or perhaps another 4xx-status-message i.e. 400).

Related

TYPO3 how to render a Page on 404 with correct status code

we are using:
TYPO3 8.7.27
RealUrl 2.5.0
following scenario - a user enters a link that does not exist within our site - so we expect the behaviour that a 404 page gets rendered - we managed to achive that but we do not have the correct status code because we used a simply redirect within the install tool:
[FE][pageNotFound_handling] = "REDIRECT:/404"
[FE][pageNotFound_handling_statheader] = "HTTP/1.0 404 Not Found"
we also use our 404 page for cHash comparison errors but thats just a sidenote.
so what happens is the user requests the data from the wrong url, we send the correct 404 followed by a redirect to a certain page.
how can we directly render a page in the first place, the url should stay the same and we just render our whole TYPO3 page (no static file) with the 404 text-information.
You should use this instead:
[FE][pageNotFound_handling] = "/404"
This will instruct TYPO3 to download the page at the given "URL" and output its content together with the expected 404 status code. Notice that it might be necessary to use an absolute URL here.
From the DefaultConfigurationDescription.php:
pageNotFound_handling
... String: Static HTML file to show (reads content and outputs with correct headers), e.g. "notfound.html" or "http://www.example.org/errors/notfound.html"
You can drop the pageNotFound_handling_statheader option since it defaults to 404.

How to route a path that ends with index.php in Slim framework

I'm using Slim Framework 2.4.2 and my .htaccess looks like this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
I've been having some trouble with routing a path that ends with index.php. For legacy support reasons, I need to be able to route /soap/index.php to my custom code, but it keeps going to my notFound handler.
I have a route like the following in my /index.php
$app->get('/soap/index.php', function () {
echo "HERE";
});
However, when I go to /soap/index.php in my browser, it get Slim's 404 Not Found handler. I have tried changing the route to /soap/index2.php, which allows me to see "HERE" in the browser, but when I use /soap2/index.php I get the same results as for original. The /soap/ directory does still exist, but /soap2/ does not, so it doesn't seem that it is Apache causing the issue because both return the same results, the Slim 404 handler. It just seems like Slim gives a 404 for any route that goes to an index.php.
I've also tried creating just a /soap/ route to see if Slim is trying to use that when I access /soap/index.php in the browser, but that still gives me a 404.
For now, I will try to just have the 404 handler detect the issue and perform the action.
In the notFound handler, I am getting "/x.php" for the response from $app->request->getPathInfo(). As I add more letters to the front they end up in the string. It's clipping the first 9 characters, which is how long the filename is. After some more looking, this was a known bug.
It is reported on GitHub here.
Updating to the newest Slim framework fixed the issue.

Response.Redirect() vs Response.RedirectPermanent()

I am new to ASP.Net 4.0, and have seen a new feature called Response.RedirectPermanent(). I have checked a few articles, but I'm unable to understand clearly the actual meaning and difference of Response.RedirectPermanent() over Response.Redirect().
According to Gunnar Peipman,
Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header.
Why do I need to check the server response such as 301, 302? And how does it get permanently redirected the page to the server?
301 response (RedirectPermanent) is very useful for SEO purposes. For example, you had a site implemented in ASP.NET WebForms and redesigned using ASP.NET MVC. You'd like to inform search engines that page /Catalog/ProductName.aspx becomes /products/product-name. Then you set 301 redirect from /Catalog/ProductName.aspx to /products/product-name and links in search engines' indices will be replaced. 302 (Redirect) is mostly for internal purposes. For example, the redirect after login (if returnUrl was set in URL).

IIS 7.5 URL Rewrite Module & Redirects

My company is embarking on a large website redirection at the moment and I decided it would give us the perfect opportunity to make the URL's more user and google friendly.
To give you a brief outline of the situation, I am the SEO guy and I am dealing with an external developer in order to redirect the website without hurting the current rankings in Google. I don't have much experience regarding sharepoint hence why I would really appreciate any assistance in understanding and knowing if there is a work around to my situation.
The website is using IIS7.5, they recently installed the URL Rewrite Module in order to create more user friendly URL's. My question is, by creating a more user friendly URL, does this cause an additional redirect?
For example: if a user types in www.domain.com this permanently (301) redirects to www.domain.com/pages/home.aspx.The developer told me that in order to rewrite the URL to display something more friendly (like www.domain.com/home) this will have to cause another permanent redirect. So in essence the process will look like this:
REQUESTING: http:// www.domain.com
SERVER RESPONSE: HTTP /1.1 301 Redirect
1) Redirecting to: http:// www.domain.com/pages/home.aspx
SERVER RESPONSE: HTTP /1.1 301 Redirect
2) Redirecting to: http:// www.domain.com/home
SERVER RESPONSE: HTTP/1.1 200 OK
Is this how the URL Rewrite Module really works? I would have thought that it would not have to create another redirect in order to create a more user friendly URL?
My second problem is this.... The redirect is happening on the same server. So here is essentially the situation:
www.old-domain.com
www.dev-domain.com
www.new-domain.com
The old-domain needs to be redirected to the new domain so we ran a test in order to see if the HTTP status codes were correct before going ahead with the project. So the developer redirected the dev-domain to the new-domain and the redirects look like this: (The developers comments in italic below)
REQUESTING: http:// www.dev-domain.com
SERVER RESPONSE: HTTP/1.1 301 Moved Permanently
1) Redirecting to: http:// www.new-domain.com/
SERVER RESPONSE: HTTP/1.1 302 Redirect
2) Redirecting to: http:// www.dev-domain.com/Pages/home.aspx
SharePoint’s alternate access mappings causes this to happen and there is no way around this.
SERVER RESPONSE: HTTP/1.1 301 Moved Permanently
3) Redirecting to: http:// www.dev-domain.com/pages/home.aspx
SERVER RESPONSE: HTTP/1.1 301 Moved Permanently
4) Redirecting to: http:// www.new-domin.com/pages/home.aspx
SERVER RESPONSE: HTTP/1.1 200 OK
The developer states the reason for redirecting back to the dev-domain then back to the new-domain is because of SharePoint's alternate access mappings and there is no way around this. Is that entirely true?
Any assitance at all will be GREATLY appreciated!

IIS6 - How do I redirect users to another site for every page with a few exceptions?

I have a website setup in IIS 6, let's say it's called http://www.this.com.
I have setup a redirection for this website to http://www.that.com which maintains the directory structure and query parameters as follows:
http://www.that.com$S$Q - using the option "The exact URL entered above"
This works great, whenever someone requests, for example:
http://www.this.com/subfolder/page.aspx?Id=1
then they end up at:
http://www.that.com/subfolder/page.aspx?Id=1
Now, I have one page, actually a handler, http://www.this.com/image.axd, which I do not want to redirect.
What is the syntax for that? I've read the Redirection Using Wildcards section here, but I can't work out how to do what seems to be something straight forward.
Note that image.axd is a handler so I can't just "right click" on it and set the redirection properties as it doesn't physically exist.
I also have a couple of other pages in subfolders which I do not want to redirect, for example:
http://www.this.com/subfolder/donotredirectthispage.aspx
Any help would be appreciated.
Edit: A couple of people have mentioned using ISAPI_Rewrite, for which I'm grateful, but I really don't want to introduce another complexity into the website configuration. IIS seems to imply I can acheive what I want using the ! and 0 through 9 variables.
Is it really not possible to do this using IIS?
My current workaround is to set the redirection properties on ALL folders and pages that I want to redirect except those I do not, but this is a management nightmare.
You could implement a custom error page for the page not found error (404) that does the redirection for you. You'd turn off the redirection in IIS. Build the logic for the redirection in your custom error page. Then configure your web site so that 404 errors redirect to your error page.
If you can install software on your IIS server, I'd recommend using a tool to rewrite your request URLs.
For IIS 6.0 I've used ISAPI_Rewrite and it works really well. It's lightweight and very configurable. There's a "Lite" version available for free and will support your requirements.
You configure the program using a text file containing rules that match HTTP requests and then write actions to perform once a rule is matched. Your instance would probably require a general redirect rule (similar to the one in IIS) and rules for your exceptions.
You should look into the possibility of using a header rewrite module, for example ISAPI_rewrite. There is a free "lite" version available that is enough for your needs.
What this can do for you is the following: Before actual pages are executed on the server, the Request headers are rewritten (or HTTP 301/302 redirects are issued) based on a configurable set of rules. The underlying server sees the remaining requests as if the client really made them in that fashion.
The following rules would leave image.axd requests alone, while redirecting everything else.
# image.axd stays unchanged ("L" is the "last rule" flag)
RewriteCond Host: www.\this\.com
RewriteRule ^.*?\bimage\.axd\b.* $0 [L]
# all requests that have not been stopped by an earlier rule
# end up here ("RP" is the "permanent redirect" flag)
RewriteCond Host: www.\this\.com
RewriteRule .* http://www.that.com$0 [RP,L]