HTACCESS: Difference between revisions
Nicole Sharp (talk | contribs) No edit summary |
Nicole Sharp (talk | contribs) No edit summary |
||
| Line 24: | Line 24: | ||
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L] | RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L] | ||
# https://www.mediawiki.org/wiki/Manual:Short_URL/Apache#Setting_up_the_rewrite_rules | # https://www.mediawiki.org/wiki/Manual:Short_URL/Apache#Setting_up_the_rewrite_rules | ||
</syntaxhighlight> | |||
== MEDIAWIKI files == | |||
# [https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset <cite>Apache HTTP Server Project Documentation</cite>: "Multipurpose Internet Mail Extension (MIME) Module"] | |||
MediaWiki source code saved as MEDIAWIKI filetype will not display in the web browser unless you set the Multipurpose Internet Mail Extension (MIME) type for MEDIAWIKI to "<code>text/plain</code>". | |||
<syntaxhighlight lang="apache"> | |||
AddType text/plain .mediawiki | |||
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype | |||
</syntaxhighlight> | |||
== character encoding == | |||
Unicode special characters encoded as Eight-Bit Unicode Transformation Format (UTF-8) in plaintext (TXT) files and in MEDIAWIKI files will not display correctly in the browser unless the character set (charset) encoding is manually set for these filetypes.  You should set the charset for each filetype individually and should not use "<syntaxhighlight lang="apache" inline="inline">AddDefaultCharset</syntaxhighlight>". | |||
<syntaxhighlight lang="apache"> | |||
AddCharset UTF-8 .mediawiki .txt | |||
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 35: | Line 55: | ||
IndexOptions Charset=UTF-8 +FancyIndexing NameWidth=* | IndexOptions Charset=UTF-8 +FancyIndexing NameWidth=* | ||
DefaultIcon /icons/000.svg | DefaultIcon /icons/000.svg | ||
AddIcon /icons/zzz.svg ^^DIRECTORY^^ | AddIcon /images/icons/filetypes/zzz.svg ^^DIRECTORY^^ | ||
AddIcon /icons/htm.svg .htm .html | AddIcon /images/icons/filetypes/7z0.svg .7z | ||
AddIcon /icons/ | AddIcon /images/icons/filetypes/css.svg .css | ||
AddIcon /icons/ | AddIcon /images/icons/filetypes/htm.svg .htm .html | ||
AddIcon /icons/ | AddIcon /images/icons/filetypes/med.svg .mediawiki | ||
AddIcon /images/icons/filetypes/png.svg .png | |||
AddIcon /images/icons/filetypes/svg.svg .svg | |||
AddIcon /images/icons/filetypes/txt.svg .txt | |||
IndexOptions +IconsAreLinks | IndexOptions +IconsAreLinks | ||
ReadmeName /footer.html | ReadmeName /footer.html | ||
# https://httpd.apache.org/docs/current/mod/mod_autoindex.html | # https://httpd.apache.org/docs/current/mod/mod_autoindex.html | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 2026-04-14T05:23:51
Resources for configuring Apache Hypertext Transfer Protocol (HTTP) Server Access (.htaccess) files.
intro
- Wikipedia: "HTACCESS"
- DreamHost Knowledge Base: "HTACCESS Overview"
- DreamHost Knowledge Base: "What Can I Do with an HTACCESS File?"
- Apache HTTP Server Project Documentation: "HTACCESS Files"
redirects
- DreamHost Knowledge Base: "How Can I Redirect and Rewrite my Uniform Resource Locators (URLs) with an HTACCESS File?"
- Wikipedia: "HTTP Status Codes"
- Mozilla Developer Network: "HTTP Response Status Codes"
- Internet Engineering Task Force (IETF) HTTP Working Group: "Internet Standard 97 (HTTP Semantics: Overview of Status Codes)"
MediaWiki shortlinks
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
# https://www.mediawiki.org/wiki/Manual:Short_URL/Apache#Setting_up_the_rewrite_rules
MEDIAWIKI files
MediaWiki source code saved as MEDIAWIKI filetype will not display in the web browser unless you set the Multipurpose Internet Mail Extension (MIME) type for MEDIAWIKI to "text/plain".
AddType text/plain .mediawiki # https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
character encoding
Unicode special characters encoded as Eight-Bit Unicode Transformation Format (UTF-8) in plaintext (TXT) files and in MEDIAWIKI files will not display correctly in the browser unless the character set (charset) encoding is manually set for these filetypes. You should set the charset for each filetype individually and should not use "AddDefaultCharset".
AddCharset UTF-8 .mediawiki .txt # https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
automatic indexing
"FancyIndexing" must be enabled before adding icons. "IconsAreLinks" can only be enabled after the icons are added.
IndexOptions Charset=UTF-8 +FancyIndexing NameWidth=* DefaultIcon /icons/000.svg AddIcon /images/icons/filetypes/zzz.svg ^^DIRECTORY^^ AddIcon /images/icons/filetypes/7z0.svg .7z AddIcon /images/icons/filetypes/css.svg .css AddIcon /images/icons/filetypes/htm.svg .htm .html AddIcon /images/icons/filetypes/med.svg .mediawiki AddIcon /images/icons/filetypes/png.svg .png AddIcon /images/icons/filetypes/svg.svg .svg AddIcon /images/icons/filetypes/txt.svg .txt IndexOptions +IconsAreLinks ReadmeName /footer.html # https://httpd.apache.org/docs/current/mod/mod_autoindex.html
HTACCESS for Nicole Sharp's Website
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
# https://www.mediawiki.org/wiki/Manual:Short_URL/Apache#Setting_up_the_rewrite_rules
IndexOptions Charset=UTF-8 +FancyIndexing NameWidth=*
DefaultIcon /icons/000.svg
AddIcon /icons/zzz.svg ^^DIRECTORY^^
AddIcon /icons/7z0.svg .7z
AddIcon /icons/htm.svg .htm .html
AddIcon /icons/pdf.svg .pdf
AddIcon /icons/svg.svg .svg
AddIcon /icons/txt.svg .txt
AddIcon /icons/xls.svg .xls .xlsm .xlsx
IndexOptions +IconsAreLinks
ReadmeName /footer.html
# https://httpd.apache.org/docs/current/mod/mod_autoindex.html
AddCharset UTF-8 .txt # https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
# Apache Hypertext Transfer Protocol Server Access (HTACCESS) for Nicole Sharp's Website: https://www.nicolesharp.net/
# Copyright (C) 2026-04-13 Nicole Sharp
# Unless otherwise noted, content on Nicole Sharp's Website is available under the Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 International Public License: https://www.nicolesharp.net/wiki/CC_BY-SA
You can use either "footer.txt" or "footer.html" to add content to the bottom of each automatically generated indexpage. For Hypertext Markup Language (HTML), I try to use the HTM file extension for webpages written by humans for humans versus the HTML file extension for webpages written by machines or for machines. The "footer.html" here is not a webpage or a valid HTML document: it is just a code snippet to be inserted before the closing </body> tag. You should not have an HTML or BODY element in the "footer.html" file.
Since this hypertext will appear frequently on many different pages, you should not use redirecting links. In the example below, this means using the full "/wiki/Creative_Commons_Attribution-ShareAlike_4.0_International_Public_License" and not the shorter "/wiki/CC_BY-SA". Avoiding wikiredirects here should reduce server load.
<p>© (Copyright) 2026 <a href="/wiki/Nicole_Sharp">Nicole Sharp</a> (NicoleSharp.net).</p> <p>Unless otherwise noted, content on this site is available under the <cite><a rel="copyright" href="/wiki/Creative_Commons_Attribution-ShareAlike_4.0_International_Public_License">Creative Commons Attribution-ShareAlike 4.0 International Public License</a> (CC BY-SA 4.0)</cite>.</p> <p><strong><a rel="home index" href="/wiki/NikkiWiki">Return to the homepage for <cite>Nicole Sharp’s Website</cite>.</a></strong></p>