Loading...
 
Skip to main content

History: htaccess

Source of version: 19

Copy to clipboard
            ! htaccess


The .htaccess-file is mainly separated in two parts
# some php/apache-settings
# rewrite rules for sefurls

The second part, the search engine friendly URLs and rewrite rules, are described in ((Rewrite Rules)). See there for more information.

!! To activate
Tiki bundles a file named _htaccess. You should __copy__ it to .htaccess

Alternatively, on Linux, you can make a symlink.

{CODE()} ln -s _htaccess .htaccess {CODE}

!! PHP Settings
In some cases it is possible to overwrite some values from the ((php.ini)) file given by your ISP, by means of a file ((php.ini)) in the tiki root folder, or by means of some changes in the .htaccess file in the tiki root folder also. In this second case, place your special .htaccess file in the tiki root directory or just rename the _htaccess file given by Tiki to .htaccess an make your changes. You can visit tiki-phpinfo.php to check whether or not your changes where successful.


!!! PHP Memory Limit
The most important setting is the php memory limit. The maximum amount of memory a script may consume. On many shared hosts this variable is set to 64MB. Tiki runs fine with 64MB but depending on your special needs and options it is necessary to uncomment and increase this value to 128MB. (which is the default value on recent PHP versions)

{CODE(wrap="1" colors="shell")}
# memory limit
php_value memory_limit 256M
{CODE}


!!! Error Display
To display php errors on your display activate / uncomment this setting. Error output is very useful during development, but it could be very dangerous in production environments. Depending on the code which is triggering the error, sensitive information could potentially leak out of your application such as database usernames and passwords or worse.
{CODE(wrap="1")}
# to activate the error display, uncomment the following line
php_flag display_errors on

# to set the error_reporting level, uncomment the following line. Values are explained here: http://www.php.net/manual/en/errorfunc.constants.php
 php_value error_reporting E_ALL
{CODE}


!!! Execution Time
PHP uses a default script execution time of 30s before a script is terminated by the server. In some cases with huge wiki pages with many plugins it´s necessary to increase the execution time to 90s
{CODE(wrap=>1)}
# increase execution time (default value in php use to be 30, and in some cases of long wiki pages with many plugins it may take longer)
php_value max_execution_time = 90     ; Maximum execution time of each script, in seconds
php_value max_input_time = 90 ; Maximum amount of time each script may spend parsing request data
{CODE}


!!! Maximum File and Post Size
The maximum allowed size for uploaded files and maximum size of POST data that PHP will accept.
{CODE(wrap=>1)}
# increase the maximum file size for uploads allowed by php for Tiki (default value in apache use to be 2M which is usually too low for pdf or documents with some images, screenshots, etc)
php_value upload_max_filesize 10M
php_value post_max_size 11M
{CODE}


!!! Include Path
{CODE(wrap=>1)}
# In some cases you may see open_basedir warnings about Smarty accessing php files that it shouldn't
# The following line (uncommented) will reset the include path to use only Tiki's files which will solve this in most cases
php_value include_path "."
{CODE}

Also see [http://tikiwiki.svn.sourceforge.net/viewvc/tikiwiki/trunk/_htaccess?view=markup|latest default htaccess from code base]

!! 12.x
{CODE(ln="1")}
# $Id: _htaccess 51002 2014-04-25 14:42:41Z jonnybradley $ [This line is used to check that this configuration file is up to date. Do not edit this line and leave it as the first line.]
# These are suggested configuration directives for use with Tiki.
# They enhance security and permit clean URLs.
# In your Tiki instance, visit tiki-admin.php?page=sefurl to make Tiki use clean URLs in generated links.
#
# To use, ideally, create a symbolic link from .htaccess to _htaccess. This will keep the configuration up-to-date.
# If you can't, do one of the following:
# - Copy _htaccess to .htaccess. Note : Do not move (rename) _htaccess, it is required for other uses (like SEFURL).
# - Add the content of this file to your httpd.conf.
# This should be repeated when the reference _htaccess file changes (when upgrading Tiki). 

#
# Please find more info here
# http://doc.tiki.org/Rewrite+Rules

# DEVELOPERS: This configuration must be kept synchronized with the configuration for other Web servers. See http://dev.tiki.org/Operating+System+independence#Keep_web.config_and_.htaccess_synchronized

#Redirect bogus directories, which otherwise cause a broken page to upload very slowly
#e.g., try yourdomain.com/bogus/ or yourdomain.com/tiki/bogus/ and see what happens
#The below may not work in all configurations depending on redirects already in place
#If certain directories containing other programs are legitimate (eg when tiki is installed in a subdirectory),
#then you will first need a condition like the following
#RewriteCond %{REQUEST_URI} !(^/otherokaydirectory/)
#Then use something like this if your tiki program is in a subdirectory
#RewriteRule ^(.+[^/])/$  /tiki/HomePage [R=301,L]
#Use this if tiki is installed in the root (above condition probably not necessary in this case)
#RewriteRule ^(.+[^/])/$  /HomePage [R=301,L]

# This prevents reading of files with certain extensions.
<FilesMatch "\.(bak|inc|lib|sh|tpl|sql)$">
	order deny,allow
	deny from all
</FilesMatch>

<FilesMatch "^(changelog.txt|_htaccess)$">
	order deny,allow
	deny from all
</FilesMatch>

# This prevents reading of tags file for developers who run ctags on their server
#<Files tags>
#	order deny,allow
#	deny from all
#</Files>

<IfModule mod_dir.c>
	DirectoryIndex index.php
	# if using wiki as homepage feature you may avoid the home page name being appended to the url by replacing the previous line with the following line
	#DirectoryIndex tiki-index.php index.php
</IfModule>

<IfModule deflate_module>
	AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

# Persistent connections: Allow multiple requests to be sent over 
# the same TCP connection. Enable if you serve a lot of static content 
# but, be aware of the possible disadvantages!
# http://httpd.apache.org/docs/current/en/mod/core.html#keepalive

# <IfModule mod_headers.c>
#    Header set Connection Keep-Alive
# </IfModule>


# Using ETags will improve the YSlow scores
FileETag none

# Expires headers: If the site is in active development, you may want to comment out this section.
<IfModule mod_expires.c>
	<FilesMatch "\.(js|png|gif|jpg|css|ico)$">
		ExpiresActive on
		ExpiresDefault "access plus 1 month"
	</FilesMatch>
</IfModule>

# if you want to use the Web Server Auth
#AuthType Basic
#AuthName "Restricted Access"
#AuthUserFile /etc/httpd/passwords
#Require valid-user 

# Handling in Tiki errors caught by Apache
# Tiki can catch some errors and deal with them by redirecting to a similar page, sending you to the search, etc. However, some errors do not reach Tiki and are only caught by Apache (ex.: filenameThatDoesntExist.php). 
# To make Tiki handle errors caught by Apache, uncomment some of the following lines and adapt the page names. You must create the pages before trying to use them. 
#ErrorDocument 404 /tiki-index.php?page=File+not+found
#ErrorDocument 500 /tiki-index.php?page=Server+error

# Permanent redirect: Add directive as the example below. This is useful if you were using another Web application or static HTML and you want to avoid broken links.
# Redirect 301 /oldpage.html /tiki-index.php?page=newpage

# Tiki requires PHP 5. If your host doesn't offer PHP 5 by default, it's possible that it can be activated by using (uncommenting) the lines below. Check with your host.
# AddType application/x-httpd-php5 .php
# AddHandler application/x-httpd-php5 .php

# to activate the error display, uncomment the following line
#php_flag display_errors on

# to set the error_reporting level, uncomment the following line. Values are explained here: http://www.php.net/manual/en/errorfunc.constants.php
# php_value error_reporting E_ALL

# increase memory (default is 128M). Use this if you are getting blank pages and strange errors 
# php_value memory_limit 256M

# increase execution time (default value in apache use to be 30, and in some cases of long wiki pages with many plugins it may take longer)
#php_value max_execution_time 90

# increase the maximum file size for uploads allowed by php for Tiki (default value in apache use to be 2M which is usually too low for pdf or documents with some images, screenshots, etc)
#php_value upload_max_filesize 10M
#php_value post_max_size 11M

# This sets the maximum time in seconds a script is allowed to parse input data, like POST and GET. 
#php_value max_input_time 90

# In some cases you may see open_basedir warnings about Smarty accessing php files that it shouldn't
# The following line (uncommented) will reset the include path to use only Tiki's files which will solve this in most cases
#php_value include_path "." 

# some features like assigning perms to a group with a name containing a quote will not work without this
#php_flag magic_quotes_gpc off

<IfModule mod_rewrite.c>
RewriteEngine On

# You may need to uncomment and fix the RewriteBase value below to suit your installation. e.g. if your Tiki is not installed directly in the web root.
# And if you get errors like "The requested URL /absolutepath/tiki-index.php was not found on this server",
# RewriteBase   /tiki

# Rewrite rules to maintain any hard-coded URLs following http://dev.tiki.org/ImgDirectoryRevamp
RewriteRule ^img/icons2/(.*)$ img/icons/$1 
RewriteRule ^pics/large/(.*)$ img/icons/large/$1
RewriteRule ^img/mytiki/(.*)$ img/icons/large/$1
RewriteRule ^pics/(.*)$ img/$1
RewriteRule ^images/(.*)$ img/icons/$1

# Apache does not pass Authorization header to CGI scripts
# Rewrite rules for passing authorisation in CGI or FGI mode
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

#If your website is a checkout
RewriteRule	.*/\.svn/.*	-	[F,L]

# If the URL points to a file then do nothing
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.*) - [L]

# Rewrite rule to make this Tiki a profiles repository (uncomment to enable)
# Set the parentId (here set as 1) to the Id of the category containing your profile pages
# See http://doc.tiki.org/Profiles for more
# Note: you need to allow tiki_p_view_category and tiki_p_export_wiki for anonymous to be a repository
#       and enable feature_wiki_export (as well as feature_wiki and feature_categories)
#RewriteRule ^profiles$             tiki-browse_categories.php?find=&deep=on&type=wiki+page&parentId=1&sort_mode=name_asc&plain&maxRecords=1000000 [L]

# Rule to make a short link to a list of object to export as a plain text sitemap
# Set the parentId (here set as 2) to the id of a category containing the objects you wish to be crawled by search engines
#
#RewriteRule ^sitemap.txt$          tiki-browse_categories.php?find=&deep=on&type=wiki+page&parentId=2&sort_mode=name_asc&links&maxRecords=1000000 [L]

RewriteRule .*                     route.php                                [L]

# access a link to any user by providing its username (exact match) after u:
#   (uncomment to enable)
#RewriteRule ^u:([A-Za-z0-9]+)       tiki-view_tracker_item.php?user=$1&view=+user           [QSA,L]
# alternative procedure to show a list of users with that string 
#   (adapt with your user tracker id and user selector field id)
#RewriteRule ^u:([A-Za-z0-9]+)       tiki-view_tracker.php?trackerId=1&filterfield=3&filtervalue\[3\]=$1           [QSA,L]

</IfModule>
{CODE}
!! Related Links
* ((Check))
* ((Search engine optimization))
* ((Rewrite Rules))
* ((apache))
* ((Lighttpd Clean URLs))
* ((Operating System independence))
* ((php.ini))
* ((Upload file size))
* ((Apache Clean URLs))
* ((php.ini))
* http://www.htaccessredirect.net/

-=Alias names for this page: =-
(alias(_htaccess)) | (alias(.htaccess))

        

History

Advanced
Information Version
Marc Laporte 24
Marc Laporte 22
Marc Laporte 21
Bernard Sfez / Tiki Specialist Updated some information about PHP version and htaccess content (I couldn’t keep both 12.x and 21.x within tabs... code broke) 20
Yves Kipondo 19
Xavier de Pedro 18
Xavier de Pedro 17
Xavier de Pedro 16
Xavier de Pedro 15
Xavier de Pedro 14
Xavier de Pedro uncommented the code lines so that they get highlighted differently from the comments, etc. and easier to read and find what new users may be looking for 13
Marc Laporte Code Plugin modified by editor. 12
Marc Laporte Code Plugin modified by editor. 11
Marc Laporte 10
Marc Laporte 9
Marc Laporte A nice site to generate 8
Marc Laporte 7
Marc Laporte 6
Marc Laporte 5
Marc Laporte 4
Marc Laporte 3
Leu Add link 2
Leu Created 1