SID-02389: Cannot get redirect from index.html to work
| Status: |
Answered |
TWiki version: |
|
Perl version: |
5.26.1 |
| Category: |
|
Server OS: |
Ubuntu 18 |
Last update: |
7 years ago |
I cannot get the redirect from / index.html to
https://mysite.com/do/view
to work.
I have set up a virtual host in apache 2.4 and used the Apache configurator generator to for my site config file.
I've tried the redirect in both .htaccess or the site config file. In either case nothing happens.
I am at complete loss. Below is my site config
Thanx
Gaby
<VirtualHost *:80>
ServerName dais-wiki.mpi-cbg.de
Redirect permanent /
https://dais-wiki.mpi-cbg.de/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin turek@mpi-cbg.de
ServerName dais-wiki.mpi-cbg.de
DocumentRoot /srv/vhosts/twiki
ErrorLog ${APACHE_LOG_DIR}/twiki_error.log
CustomLog ${APACHE_LOG_DIR}/twiki_access.log combined
# Autogenerated httpd.conf file for TWiki.
# Generated at
http://twiki.org/cgi-bin/view/TWiki/ApacheConfigGenerator
# We set an environment variable called blockAccess.
#
# Setting a
BrowserMatchNoCase to ^$ is important. It prevents TWiki from
# including its own topics as URLs and also prevents other TWikis from
# doing the same. This is important to prevent the most obvious
# Denial of Service attacks.
#
# You can expand this by adding more
BrowserMatchNoCase statements to
# block evil browser agents trying the impossible task of mirroring a twiki
BrowserMatchNoCase ^Accoona blockAccess
BrowserMatchNoCase ^ActiveAgent blockAccess
BrowserMatchNoCase ^Attache blockAccess
BrowserMatchNoCase BecomeBot blockAccess
BrowserMatchNoCase ^bot blockAccess
BrowserMatchNoCase Charlotte/ blockAccess
BrowserMatchNoCase ^ConveraCrawler blockAccess
BrowserMatchNoCase ^CrownPeak-HttpAgent blockAccess
BrowserMatchNoCase ^EmailCollector blockAccess
BrowserMatchNoCase ^EmailSiphon blockAccess
BrowserMatchNoCase ^e-SocietyRobot blockAccess
BrowserMatchNoCase ^Exabot blockAccess
BrowserMatchNoCase ^FAST blockAccess
BrowserMatchNoCase ^FDM blockAccess
BrowserMatchNoCase ^GetRight/6.0a blockAccess
BrowserMatchNoCase ^GetWebPics blockAccess
BrowserMatchNoCase ^Gigabot blockAccess
BrowserMatchNoCase ^gonzo1 blockAccess
BrowserMatchNoCase ^Google\sSpider blockAccess
BrowserMatchNoCase ^ichiro blockAccess
BrowserMatchNoCase ^ie_crawler blockAccess
BrowserMatchNoCase ^iGetter blockAccess
BrowserMatchNoCase ^IRLbot blockAccess
BrowserMatchNoCase Jakarta blockAccess
BrowserMatchNoCase ^Java blockAccess
BrowserMatchNoCase ^KrakSpider blockAccess
BrowserMatchNoCase ^larbin blockAccess
BrowserMatchNoCase ^LeechGet blockAccess
BrowserMatchNoCase ^LinkWalker blockAccess
BrowserMatchNoCase ^Lsearch blockAccess
BrowserMatchNoCase ^Microsoft blockAccess
BrowserMatchNoCase ^MJ12bot blockAccess
BrowserMatchNoCase MSIECrawler blockAccess
BrowserMatchNoCase ^MSRBOT blockAccess
BrowserMatchNoCase ^noxtrumbot blockAccess
BrowserMatchNoCase ^NutchCVS blockAccess
BrowserMatchNoCase ^RealDownload blockAccess
BrowserMatchNoCase ^Rome blockAccess
BrowserMatchNoCase ^Roverbot blockAccess
BrowserMatchNoCase ^schibstedsokbot blockAccess
BrowserMatchNoCase ^Seekbot blockAccess
BrowserMatchNoCase ^SiteSnagger blockAccess
BrowserMatchNoCase ^SiteSucker blockAccess
BrowserMatchNoCase ^Snapbot blockAccess
BrowserMatchNoCase ^sogou blockAccess
BrowserMatchNoCase ^SpiderKU blockAccess
BrowserMatchNoCase ^SpiderMan blockAccess
BrowserMatchNoCase ^Squid blockAccess
BrowserMatchNoCase ^Teleport blockAccess
BrowserMatchNoCase ^User-Agent\: blockAccess
BrowserMatchNoCase VoilaBot blockAccess
BrowserMatchNoCase ^voyager blockAccess
BrowserMatchNoCase ^W3C blockAccess
BrowserMatchNoCase ^w3search blockAccess
BrowserMatchNoCase ^Web\sDownloader blockAccess
BrowserMatchNoCase ^WebCopier blockAccess
BrowserMatchNoCase ^WebDevil blockAccess
BrowserMatchNoCase ^WebSec blockAccess
BrowserMatchNoCase ^WebVac blockAccess
BrowserMatchNoCase ^Webwhacker blockAccess
BrowserMatchNoCase ^Webzip blockAccess
BrowserMatchNoCase ^Wells blockAccess
BrowserMatchNoCase ^WhoWhere blockAccess
BrowserMatchNoCase www\.netforex\.org blockAccess
BrowserMatchNoCase ^WX_mail blockAccess
BrowserMatchNoCase ^yacybot blockAccess
BrowserMatchNoCase ^ZIBB blockAccess
BrowserMatchNoCase ^$ blockAccess
<IfModule mod_perl.c>
# Mod_perl preloading
PerlSwitches -T
</IfModule>
# The
ScriptAlias defines the bin directory as a directory where CGI
# scripts are allowed.
# The first parameter will be part of the URL to your installation e.g.
#
http://example.com/do/view/
...
# The second parameter must point to the physical path on your disc.
ScriptAlias /do "/srv/vhosts/twiki/bin"
# The Alias defines a url that points to the twiki pub directory, which
# is the root of file attachments.
# Secure file attachments by using
ScriptAlias with viewfile script.
Alias /pub/TWiki "/srv/vhosts/twiki/pub/TWiki"
Alias /pub/Sandbox "/srv/vhosts/twiki/pub/Sandbox"
ScriptAlias /pub "/srv/vhosts/twiki/bin/viewfile"
# Block access to typical spam related attachments
# Except the TWiki directory which is read only and does have attached html files.
SetEnvIf Request_URI "/pub/.*\.[hH][tT][mM][lL]?$" blockAccess
SetEnvIf Request_URI "/pub/TWiki/.*\.[hH][tT][mM][lL]?$" blockAccess
# This specifies the options on the TWiki scripts directory. The
ExecCGI # and
SetHandler tell apache that it contains scripts. "Require all granted"
# lets any IP address access this URL.
<Directory "/srv/vhosts/twiki/bin">
AllowOverride None
Require all granted
Deny from env=blockAccess
Options
ExecCGI FollowSymLinks SetHandler cgi-script
# Password file for TWiki users
AuthUserFile /srv/vhosts/twiki/data/.htpasswd
AuthName 'Enter your
WikiName: (First name and last name, no space, no dots, capitalized, e.g.
JohnSmith)'
AuthType Basic
# File to return on access control error (e.g. wrong password)
ErrorDocument 401 /do/view/TWiki/TWikiRegistration
</Directory>
# This sets the options on the pub directory, which contains attachments and
# other files like CSS stylesheets and icons.
AllowOverride None stops a
# user installing a .htaccess file that overrides these options.
# Note that files in pub are
not protected by TWiki Access Controls,
# so if you want to control access to files attached to topics you need to
# block access to the specific directories same way as the
ApacheConfigGenerator # blocks access to the pub directory of the Trash web
<Directory "/srv/vhosts/twiki/pub">
Options None
AllowOverride None
Require all granted
Deny from env=blockAccess
# This line will redefine the mime type for the most common types of scripts
AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
#add an Expires header that is sufficiently in the future that the browser does not even ask if its uptodate
# reducing the load on the server significantly
#IF you can, you should enable this - it
will improve your twiki experience, even if you set it to under one day.
# you may need to enable expires_module in your main apache config
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|gif|png|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 11 days"
</filesmatch>
</ifmodule>
</Directory>
# Spammers are known to attach their stuff and then move it to trash where it remains unnoticed.
# We prevent viewing any attachments directly from pub
<Directory "/srv/vhosts/twiki/pub/Trash">
deny from all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/dais-srv1.pem
SSLCertificateKeyFile /etc/ssl/private/dais-srv1.key
</VirtualHost>
--
Gabriella Turek - 2019-02-01
Discussion and Answer
For "Redirect" directive, make sure the "mod_alias" module is enabled.
In your :80, you could redirect directly to your TWiki home, e.g.
Redirect permanent / https://dais-wiki.mpi-cbg.de/do/view/Main/WebHome
If a visitor comes in via https, you also need a redirect from :443, e.g.
Redirect permanent / https://dais-wiki.mpi-cbg.de/do/view/Main/WebHome
Also,
DocumentRoot /srv/vhosts/twiki could be a security issue. The twiki root should not be exposed to the outside; only twiki/bin as script directory using
ScriptAlias, and twiki/pub as an html directory using
Alias. Set the
DocumentRoot do something outside, such as
DocumentRoot /srv/vhosts/twiki-html.
--
Peter Thoeny - 2019-02-01
Thank you Peter. The redirection on port 80 works fine as you suggested, but the 443 redirection does not work. I get "You don't have permission to access / on this server." I have removed the
DocumentRoot directive
--
Gabriella Turek - 2019-02-04
OK, there were a number of problems. I am serving both virtual hosts and regular web pages. Without the
DocumentRoot directive it was defaulting to the regular web pages directory hence the error message. So I created the twiki-html directory for just the .htaccess and index.html file. Now everything works.
--
Gabriella Turek - 2019-02-04
--
Gabriella Turek - 2019-02-04
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.