set TYPO3 into maintenance mode - typo3

I added the following code to the localconf.php:
$TYPO3_CONF_VARS['BE']['adminOnly'] = '2';
$TYPO3_CONF_VARS['FE']['pageUnavailable_force'] = '1';
$TYPO3_CONF_VARS['FE']['pageUnavailable_handling'] = 'http://www.somedomain.com/maintenance';
$TYPO3_CONF_VARS['FE']['pageUnavailable_handling_statheader'] = 'HTTP/1.0 503 Service Temporarily Unavailable';
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '127.0.0.1,::1,1.2.3.4';
1.2.3.4 is my IP address. http://www.somedomain.com/maintenance is on another webserver (not the webserver where the TYPO3 installation is). I get the following message Moved Permanently - The document has moved here. How do I make the correct redirect? I tried to put a html-file on the webserver where the TYPO3 installation is, but than I get
Oops, an error occured!
Reason: This page is temporarily unavailable.
Additionally, http://www.domain.com/maintenance.html was not
found while trying to retrieve the error document.
What I'm doing wrong?

The value in pageUnavailable_handling will be fetched by TYPO3, parse and then returned to the browser. Thus if you want to point to another server, then you either have to send a 30x header and do a redirect inside the HTML document or you have to setup a redirect rule within .htaccess.
I would do the later.

REDIRECT should solve your problem.
$TYPO3_CONF_VARS['FE']['pageUnavailable_handling'] = 'REDIRECT:http://www.somedomain.com/maintenance';
Other options are READFILE for static html pages or USER_FUNCTION for, well user functions ;-)

Related

TYPO3 error 404 instead redicrect

I have such problem: If page on my sites doesn't exists it always does redirect at main page, but I want to display 404 error.
Example: example.com/sdasadsasad - I see main page. How I can fix it? I tried add in localconfiguration
'pageNotFound_handling' = '/';
'pageNotFound_handling_statheader' = 'HTTP/1.1 404 Not Found';
but it doesn't help.
TYPO3 7.6.11
Look in the description of the install tool for the settings. There is described what setting doing what.
So an String in pageNotFound_handling will fetch the page entered and display this, true or 1 will display an error message.
I recommand to create an error page like example.com/404.html within TYPO3 and enter 404.html in pageNotFound_handling so you can customize the error.
If you want only to shown an error enter trueor 1 in the pageNotFound_handling setting.
We were experiencing the same problem. We have curl enabled ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = 1). Due to our configuration, curl was not able to fetch the error page because the SSL certificate could not be verified.
Be careful, the following idea is ugly:
You might find out more about the problem by editing TypoScriptFrontendController.php: Find the function pageErrorHandler (about line 2000 -- who writes such long files?!), find the call to GernalUtility::getUrl() and add as fourth parameter a new array variable. var_dump it instead of the call to HttpUtility::redirect. You should get the curl error if there is one.

Checking user ip address after redirect

As part of a session security feature I am checking $ENV{REMOTE_ADDR} to make sure the users IP is the same during the whole stay on a website.
Some parts of the website show a waiting screen, if for example the rendering of a file takes some seconds, and I redirect the user to a result screen by the use of a meta tag <meta http-equiv="refresh" content="$time; URL=…">.
Unfortunately after this redirect the $ENV{REMOTE_ADDR} variable does not return the users IP but the one from the server.
Is there something I am missing to get this to work properly and/or are there alternatives I could use to redirect the user?
For various reasons htaccess or http-header redirects are not an option and I don't want to use JavaScript for this.
I am already using a 'click me' button to allow the user to manually skipping the wait.
You could try to alter between temporary/permanent type of redirect. Check in server logs, the the http code is 301 or 302?
I misread the accesslogs … it was actually a different script executed on the server, therefore having the servers IP, which caused all this.

Drupal - need redirect to specified page when node is deleted

I'm using the pathologic module, and currently when a node is deleted users will get a 404 error. I want to set up a Rule such that when ANY node is deleted, a redirect is put in place to send users looking for that path to the HOME page.
Do I need Rules for this, and if so, what is the best method? I haven't been able to successfully get this to work so far because of the interaction between the nid and the pathologic-created redirect. Many of my users have been sent URLs in email, etc. and I don't want them to get a 404.
Thanks in advance!
One soulition could be for you:
install https://www.drupal.org/project/hook_post_action module
write your own module in which you implement hook_node_postdelete($node) in which you set a drupal_goto()

Redirect to same named page in directory structure before path changes

Well, say I have a number of html pages in my web. The case is that I´m doing changes sometimes in the directory structure, so when anybody try to access to a determinated URL, it's possible that such URL does not exit. The files names don't change but so do the paths.
As far as I now, the server takes the user to a "404" page that can be customized. Is possible to customize the page in this way?:
The user tries oneweb.com/oldpath/page.html; which does not exist.
A 404 customized page is launched
404 page runs an script IS THIS POSSIBLE?
The script is given the name of the file WHERE IS STORED SUCH NAME?
The script search the entire directory structure to find page.html HOW TO ACCESS TO THE STRUCTURE
The file is found and the new URL is stored: oneweb.com/newpath/page.html
a link appears showing the new URL
Maybe this process is relatively common and I can find some related code or tutorial?
Are you using Apache? Linux?
Add a 404 handler
ErrorDocument 404 /404.php
Then use 404.php to parse the url. This simple example just grabs everything after the last / in the URI so http://example.com/foo/bar/page.html would put page.html in $url:
$url = end(explode('/', $_SERVER['REQUEST_URI']));
Then use one of the comment example functions in http://php.net/manual/en/function.readdir.php to search your directory and find the file.
Then do a header 301 redirect
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: http://example.com/' . $file_path);

Codeigniter Facebook app POST method AND query_string

I have a toy facebook app I'm playing with so I can understand how it all works. It's fine if you go the the app like this: http://apps.facebook.com/pushup-challenge/ (and connect it). But if you then go to it from your facebook page, FB uses the URL http://apps.facebook.com/pushup-challenge/?ref=bookmarks.
In my log file, I see that FB is POSTing the data and including the /?ref=bookmarks to it's call to my codeigniter system. This is causing it to either say "invalid URI parameters" or give me a 404, depending on if I've edited the system/core/URI.php file to add rawurlencode() to a particular call.
I've tried using mod_rewrite to get rid of the query_string, too, but since it's POSTing, it doesn't appear to be working (though I'm not exactly sure why).
Has anyone else run into this? How did you fix it?
Thanks in advance,
Hans
try $config['uri_protocol'] = “PATH_INFO”; and set enable_query_strings = TRUE
or
set
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=';
in config.php
Because it isn't calling your file by name (just ?ref=bookmarks) the server runs thru the standard default files: index.htm, index.html, index.asp. Because you need to accept a POST, you need a server that allows POSTs to htm & html if you choose to use those. Index.asp will accept POSTs on most servers, and that works for me.
SOLUTION: Add a file (index.asp), that calls the real app that you named in the App settings.