Can I use the rewrite engine (mod_rewrite) for my PHP scripts?
The rewrite engine (mod_rewrite) can be used to automatically convert URLs.
mod_rewrite is installed in all current STRATO hosting packages and can be activated by you.
Activate mod_rewrite
It is sufficient to store an .htaccess file with the following entry in the root directory or in the desired directory of the webspace:
RewriteEngine on |
This is followed by the individual RewriteRules, which you can determine yourself. Most applications (e.g. Typo3, Joomla or Wordpress) come with their own .htaccess. With these applications, it is usually sufficient to rename the .htaccess supplied or to activate it via the administration.
We can only give you advice on how to activate mod_rewrite.
Example: replace desiredname.com with www.desiredname.com
mod_rewrite is an Apache module and is most commonly used to redirect URLs or to shorten extremely long URLs. Based on a parser (converter) for regular expressions, the requested URL can be manipulated. The aim here is usually to optimise the web pages for search engines.
A simple example of using mod_rewrite might look like this. The .htaccess contains the following content:
RewriteEngine on RewriteCond %{http_host} ^desiredname.com [nc] RewriteRule ^(.*)$ http://www.desiredname.com/$1 [r=301,nc] |
With this simple redirect rule, all calls to the domain desiredname.com are redirected to www.desiredname.com. Background: Some search engines like it when the content of a domain is only accessible via one address.
Example: replace desiredname.com/index.html with desiredname.com/index.php
RewriteEngine on RewriteRule index.html$ index.php In the example, the domain is called up via http://www.desiredname.com/index.html forwarded to http://www.desiredname.com/index.php |
Further information about mod_rewrite
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.2/misc/rewrite.html
The Apache directive RewriteOptions is not allowed.