Apache

From Torben's Wiki
Revision as of 20:33, 11 September 2018 by Torben (talk | contribs) (→‎Password)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

.htaccess

basics

#a different version can be stored in each subfolder 

# set the timezone
SetEnv TZ Europe/Berlin

# do not generate a index.htm listing of the files
Options -Indexes
# can be turned on for a specifiv subfolder by using another .htaccess 
# in that folder containing "Options Indexes" without the "-"

 # disable the display on index-pages for files matching * = all
IndexIgnore *.jpg

# ensure that http://entorb.net --> http://www.entorb.net
RewriteCond %{HTTP_HOST} !^www\.entorb\.net$
RewriteRule ^(.*)$ http://www.entorb.net/$1 [L,R=301]

Password

Ask for a password when accessing a folder

[1] Create a new passwd file

htpasswd -c -m /some/path/passwd.file myUser

Add another user

htpasswd -m /some/path/passwd.file myUser2

( at Uberspace the <passwd.file> has to be located below /var/www/virtual/<USER>/ )

.htaccess:

AuthType Basic
AuthName "some Text"
AuthUserFile /some/path/passwd.file
#AuthGroupFile /www/passwords/group.file
Require User myUser

URL Rewrite for wiki

see [2] , [3] or [4]

my case: wiki stored unter folder wiki, using virtual folder wickie

# Wiki: convert request using /index.php?title=XYZ ->/XYZ
# only apply the following to wiki urls
RewriteCond %{REQUEST_URI} .*(wickie|wiki).* [nocase]
RewriteCond %{THE_REQUEST} \?title=(.+)\ HTTP
RewriteRule ^.*$ http://www\.entorb\.net/wickie/%1? [R=301,L]

# Short URLs for Wiki
#http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_DreamHost_Shared_Hosting
RewriteEngine On
# only apply the following to wiki urls
RewriteCond %{REQUEST_URI} .*(wickie|wiki).* [nocase]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /wiki/index.php?title=$1 [L,QSA]
# in LocalSettings.php
$wgUsePathInfo = true;
$wgScriptPath       = "/wiki"; # real path
$wgScriptExtension  = ".php";
$wgScript           = "$wgScriptPath/index$wgScriptExtension";
$wgArticlePath = "/wickie/$1"; # virtual path

robots.txt

Place in webservers-root-dir. To keep search robots out of some of your folders. Attention: this file my be a hint for intruders...

User-agent: *
Disallow: /privateStuff/
Disallow: /Gallery/