Difference between revisions of "URL Rewrite"

From Hostek.com Wiki
Jump to: navigation, search
(Mura)
(Magento)
Line 396: Line 396:
  
 
=== Magento ===
 
=== Magento ===
 +
=====Linux (.htaccess)=====
 +
<source lang="apache">
 +
############################################
 +
## uncomment these lines for CGI mode
 +
## make sure to specify the correct cgi php binary file name
 +
## it might be /cgi-bin/php-cgi
 +
 +
#    Action php5-cgi /cgi-bin/php5-cgi
 +
#    AddHandler php5-cgi .php
 +
 +
############################################
 +
## GoDaddy specific options
 +
 +
#  Options -MultiViews
 +
 +
## you might also need to add this line to php.ini
 +
##    cgi.fix_pathinfo = 1
 +
## if it still doesn't work, rename php.ini to php5.ini
 +
 +
############################################
 +
## this line is specific for 1and1 hosting
 +
 +
    #AddType x-mapp-php5 .php
 +
    #AddHandler x-mapp-php5 .php
 +
 +
############################################
 +
## default index file
 +
 +
    DirectoryIndex index.php
 +
 +
<IfModule mod_php5.c>
 +
 +
############################################
 +
## adjust memory limit
 +
 +
    php_value memory_limit 512M
 +
    php_value max_execution_time 18000
 +
 +
############################################
 +
## disable magic quotes for php request vars
 +
 +
    php_flag magic_quotes_gpc off
 +
 +
############################################
 +
## disable automatic session start
 +
## before autoload was initialized
 +
 +
    php_flag session.auto_start off
 +
 +
############################################
 +
## enable resulting html compression
 +
 +
    #php_flag zlib.output_compression on
 +
 +
###########################################
 +
# disable user agent verification to not break multiple image upload
 +
 +
    php_flag suhosin.session.cryptua off
 +
 +
###########################################
 +
# turn off compatibility with PHP4 when dealing with objects
 +
 +
    php_flag zend.ze1_compatibility_mode Off
 +
 +
</IfModule>
 +
 +
<IfModule mod_security.c>
 +
###########################################
 +
# disable POST processing to not break multiple image upload
 +
 +
    SecFilterEngine Off
 +
    SecFilterScanPOST Off
 +
</IfModule>
 +
 +
<IfModule mod_deflate.c>
 +
 +
############################################
 +
## enable apache served files compression
 +
## http://developer.yahoo.com/performance/rules.html#gzip
 +
 +
    # Insert filter on all content
 +
    ###SetOutputFilter DEFLATE
 +
    # Insert filter on selected content types only
 +
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
 +
 +
    # Netscape 4.x has some problems...
 +
    #BrowserMatch ^Mozilla/4 gzip-only-text/html
 +
 +
    # Netscape 4.06-4.08 have some more problems
 +
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip
 +
 +
    # MSIE masquerades as Netscape, but it is fine
 +
    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 +
 +
    # Don't compress images
 +
    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 +
 +
    # Make sure proxies don't deliver the wrong content
 +
    #Header append Vary User-Agent env=!dont-vary
 +
 +
</IfModule>
 +
 +
<IfModule mod_ssl.c>
 +
 +
############################################
 +
## make HTTPS env vars available for CGI mode
 +
 +
    SSLOptions StdEnvVars
 +
 +
</IfModule>
 +
 +
<IfModule mod_rewrite.c>
 +
 +
############################################
 +
## enable rewrites
 +
 +
    Options +FollowSymLinks
 +
    RewriteEngine on
 +
 +
############################################
 +
## you can put here your magento root folder
 +
## path relative to web root
 +
 +
    #RewriteBase /magento/
 +
 +
############################################
 +
## workaround for HTTP authorization
 +
## in CGI environment
 +
 +
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 +
 +
############################################
 +
## always send 404 on missing files in these folders
 +
 +
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
 +
 +
############################################
 +
## never rewrite for existing files, directories and links
 +
 +
    RewriteCond %{REQUEST_FILENAME} !-f
 +
    RewriteCond %{REQUEST_FILENAME} !-d
 +
    RewriteCond %{REQUEST_FILENAME} !-l
 +
 +
############################################
 +
## rewrite everything else to index.php
 +
 +
    RewriteRule .* index.php [L]
 +
 +
</IfModule>
 +
 +
 +
############################################
 +
## Prevent character encoding issues from server overrides
 +
## If you still have problems, use the second line instead
 +
 +
    AddDefaultCharset Off
 +
    #AddDefaultCharset UTF-8
 +
 +
<IfModule mod_expires.c>
 +
 +
############################################
 +
## Add default Expires header
 +
## http://developer.yahoo.com/performance/rules.html#expires
 +
 +
    ExpiresDefault "access plus 1 year"
 +
 +
</IfModule>
 +
 +
############################################
 +
## By default allow all access
 +
 +
    Order allow,deny
 +
    Allow from all
 +
 +
############################################
 +
## If running in cluster environment, uncomment this
 +
## http://developer.yahoo.com/performance/rules.html#etags
 +
 +
    #FileETag none
 +
</source>
 +
 +
=====Windows (web.config)=====
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
 +
<configuration>
 +
  <system.webServer>
 +
    <rewrite>
 +
      <rules>
 +
        <rule name="Magento SEO: remove index.php from URL">
 +
          <match url="^(?!index.php)([^?#]*)(\\?([^#]*))?(#(.*))?" />
 +
            <conditions>
 +
              <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
 +
              <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
 +
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
 +
            </conditions>
 +
          <action type="Rewrite" url="index.php/{R:0}" />
 +
        </rule>
 +
      </rules>
 +
    </rewrite>
 +
  </system.webServer>
 +
</configuration>
 +
</source>
 +
 
=== Mura ===
 
=== Mura ===
 
=====Linux (.htaccess)=====
 
=====Linux (.htaccess)=====

Revision as of 23:44, 19 July 2015

Contents

Overview

Platform Compatibility

Apache (Linux)

Directives - RewriteEngine

Directives - Rewrite Options

Directives - RewriteLog

Directives - RewriteLogLevel

Directives - RewriteLock

Directives - RewriteMap

Directives - RewriteBase

Directives - RewriteCond

Directives - RewriteRule

Flags - RewriteRules

Flags - RewriteCond

Variables - HTTP Headers

Variables - Request

Variables - Server Internals

Variables - Special

Variables - Time

<IfModule>

Common Issues - Filename

Common Issues - AllowOverride

Common Issues - Syntax

Common Issues - Special Characters

Common Issues - Nesting

Additional Resources

IIS (Windows)

Inbound Rules

Outbound Rules

Inheritance

Rewrite Conditions

Server Variables

String Functions

Rewrite Maps

Externalization of Rewrite Rules

Additional Resources

ISAPIRewrite (Windows)

Unsupported Features

Common Issues - Leading Slashes

Common Issues - Windows Filename Requirements

Additional Resources

Redirect Codes

301 - Moved Permanently

Built to be search engine friendly, the 301 redirect is best used for redirects which will not change. Robots will crawl and index these redirects.

There are no limit to how many redirects you can perform from "Site A" to "Site B". However, there is a limit to how many redirects you can chain together. (Example: Site A -> Site B -> Site C -> Site D -> Site E) Google suggest that you use no more than 3, as each redirect can cause a certain amount of latency.

"If you are getting up to the four or five hops, then that's starting to get a little bit dangerous, in the sense that Google might decide not to follow all of those redirects."

-Change page URLs with 301 redirects, video recording, Google Webmasters

302 - Found

The 302 redirect is an older standard than most. Today it is mainly used to redirect legacy browsers that do not support HTTP/1.1 (RFC 2616) status codes. (Such as 303 and 307)

303 - See Other

The purpose of the 303 status code, as defined by Semantic Web theory, is one way of responding to a request for a URI that identifies a real-world object.

An example of this would be if the URI, http://www.example.com/person/Brian, identifies a person, Brian, then it would not be appropriate for the server to return a "200" status code (OK) to the GET request, as the server cannot deliver the person "Brian". A 303 would redirect this request to a separate URI that has a description for the person "Brian".

304 - Not Modified

The status code 304 denotes that the requested resource has not changed since the version specified by the request headers. This is most commonly seen when the browser is serving cached objects for a website.

307 - Temporary Redirect

The 307 redirect is used when the request should be repeated with a different URI; however, future requests should still use the originating URI. In addition to this, the request method can not be changed when reissuing the original request. The the original request starts as a POST method, then the repeated request must also be a POST method.

308 - Permanent Redirect

The 308 status code is very similar to 302 and 301 redirects. There is a slight change to the rules however. Status code 308 does not allow for the HTTP method to change. All redirects must match the originating method.

Regular Expressions

Anchors

Character Classes

Character Classes - POSIX

Assertions

Quantifiers

Escape Sequences

Common Meta Characters

Special Characters

Groups and Ranges

Pattern Modifiers

String Replacement

Testing Tools

Below is a brief list of online tools to create and test regular expressions.

Additional Resources

Below is a list of useful online resource to help you learn and familiarize yourself with regular expressions.

Common Rewrite Rules

Redirect to www

Linux (Apache)

# Add WWW Prefix
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
</IfModule>

Windows (IIS)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect to www" stopProcessing="true">
                    <match url="^(.*)$"  ignoreCase="true" />
                    <action type="Rewrite" url="/http://www.example.com/{R:1}"  />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Redirect to non-www

Linux (Apache)

# Remove WWW Prefix
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
</IfModule>

Windows (IIS)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect to non-www" stopProcessing="true">
                    <match url="^(.*)$"  />
                    <action type="Rewrite" url="/http://example.com/{R:1}"  />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Redirect Single Page

# Redirect page
Redirect 301 /old.html /new.html

Redirect Entire Site

# Redirect entire domain
Redirect 301 / http://www.example.com

Redirect Entire Site with Query String

Redirect Entire Site to Sub-Folder

Redirect Sub-Folder to Different Site

Redirect to Different File Extension

# Redirect to new file extension
RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Redirect to New Domain

# Redirect to new domain
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^(www\.)?newdomain\.com$ [NC]
    RewriteRule .* http://newdomain.com%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^(www\.)?newdomain\.com$ [NC]
    RewriteRule .* https://newdomain.com%{REQUEST_URI} [R=301,L]
</IfModule>

Redirect Unsecure (HTTP) to Secure (HTTPS)

# Redirect to HTTPS
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>

Redirect Mobile Users

# Redirect mobile devices
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule ^ http://m.example.com%{REQUEST_URI} [R,L]
</IfModule>

Block IP Addresses

# Block IP addresses
Order Deny,Allow
Deny from 1.2.3.4

Block All Except IP Addresses

# Block all except IP addresses
Order Deny,Allow
Deny from all
Allow from 1.2.3.4

Block Bad Bots

# Block bad bots
<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteCond %{HTTP_USER_AGENT} ^Bot [OR]
    RewriteCond %{HTTP_USER_AGENT} ^AnotherBotName
    RewriteRule ^.* - [F,L]
</IfModule>

Prevent Directory Listing

# Prevent directory listing
Options All -Indexes

Custom Error Pages

# Custom error pages
ErrorDocument 400 /error400.html
ErrorDocument 401 /error401.html
ErrorDocument 403 /error403.html
ErrorDocument 404 /error403.html
ErrorDocument 500 /error500.html

Follow Symbolic Links

# Follow symbolic links
Options +FollowSymLinks

Redirect to Maintenance Page

# Redirect to maintenance page
<IfModule mod_rewrite.c>
    RewriteCond %{REMOTE_ADDR} !^64\.207\.234\.198$
    RewriteCond %{REQUEST_URI} !^/maintenance\.html$ [NC]
    RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|svg|swf|css|ico|js)$ [NC]
    RewriteRule .* /maintenance.html [R=302,L]
</IfModule>

Prevent Image Hotlinking

# Prevent hotlinking
<IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} ^https?://([^/]+)/ [NC]
    RewriteCond %1#%{HTTP_HOST} !^(.+)#\1$
    RewriteRule \.(jpg|jpeg|png|gif|swf|svg)$ - [NC,F,L]
</IfModule>

Compress Common Filetypes

# Compress common filetypes
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Application-Specific Rewrite Rules

CakePHP

CodeIgniter

# CodeIgniter permalinks
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

concrete5

# Concrete5 permalinks
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

DotNetNuke

Joomla

# Joomla permalinks
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/index\.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L]
</IfModule>

Magento

Linux (.htaccess)
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
 
#    Action php5-cgi /cgi-bin/php5-cgi
#    AddHandler php5-cgi .php
 
############################################
## GoDaddy specific options
 
#   Options -MultiViews
 
## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini
 
############################################
## this line is specific for 1and1 hosting
 
    #AddType x-mapp-php5 .php
    #AddHandler x-mapp-php5 .php
 
############################################
## default index file
 
    DirectoryIndex index.php
 
<IfModule mod_php5.c>
 
############################################
## adjust memory limit
 
    php_value memory_limit 512M
    php_value max_execution_time 18000
 
############################################
## disable magic quotes for php request vars
 
    php_flag magic_quotes_gpc off
 
############################################
## disable automatic session start
## before autoload was initialized
 
    php_flag session.auto_start off
 
############################################
## enable resulting html compression
 
    #php_flag zlib.output_compression on
 
###########################################
# disable user agent verification to not break multiple image upload
 
    php_flag suhosin.session.cryptua off
 
###########################################
# turn off compatibility with PHP4 when dealing with objects
 
    php_flag zend.ze1_compatibility_mode Off
 
</IfModule>
 
<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload
 
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>
 
<IfModule mod_deflate.c>
 
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
 
    # Insert filter on all content
    ###SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
 
    # Netscape 4.x has some problems...
    #BrowserMatch ^Mozilla/4 gzip-only-text/html
 
    # Netscape 4.06-4.08 have some more problems
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip
 
    # MSIE masquerades as Netscape, but it is fine
    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
    # Don't compress images
    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 
    # Make sure proxies don't deliver the wrong content
    #Header append Vary User-Agent env=!dont-vary
 
</IfModule>
 
<IfModule mod_ssl.c>
 
############################################
## make HTTPS env vars available for CGI mode
 
    SSLOptions StdEnvVars
 
</IfModule>
 
<IfModule mod_rewrite.c>
 
############################################
## enable rewrites
 
    Options +FollowSymLinks
    RewriteEngine on
 
############################################
## you can put here your magento root folder
## path relative to web root
 
    #RewriteBase /magento/
 
############################################
## workaround for HTTP authorization
## in CGI environment
 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 
############################################
## always send 404 on missing files in these folders
 
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
 
############################################
## never rewrite for existing files, directories and links
 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
 
############################################
## rewrite everything else to index.php
 
    RewriteRule .* index.php [L]
 
</IfModule>
 
 
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
 
    AddDefaultCharset Off
    #AddDefaultCharset UTF-8
 
<IfModule mod_expires.c>
 
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
 
    ExpiresDefault "access plus 1 year"
 
</IfModule>
 
############################################
## By default allow all access
 
    Order allow,deny
    Allow from all
 
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
 
    #FileETag none
Windows (web.config)
<?xml version="1.0" encoding="UTF-8"?> 
 
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Magento SEO: remove index.php from URL">
          <match url="^(?!index.php)([^?#]*)(\\?([^#]*))?(#(.*))?" />
            <conditions>
              <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
          <action type="Rewrite" url="index.php/{R:0}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Mura

Linux (.htaccess)
# Apache mod_rewrite Docs: http://httpd.apache.org/docs/current/rewrite/
# Intro: http://httpd.apache.org/docs/current/rewrite/intro.html
# Flags: http://httpd.apache.org/docs/current/rewrite/flags.html
 
Options All -Indexes
Options +FollowSymLinks
 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
 
# Rewrite only nonexistent file or directory path
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
# -------------------------------------------------------------------------------
# MURA REWRITE OPTIONS
#
# NOTE: If running on Tomcat with sites using the SiteID in the URL
# a custom servlet mapping will be required for each site.
# Instructions: http://docs.getmura.com/v6/installation-setup/how-to-add-a-servlet-mapping-for-your-siteid-to-tomcat/
# -------------------------------------------------------------------------------
 
# OPTION 1 :: WITHOUT SiteID
# In /config/settings.ini.cfm, set both siteidinurls and indexfileinurls to 0   
# and reload the Mura application
RewriteRule ^(.*) /index.cfm/$1 [NC,QSA,PT]
 
# OPTION 2 :: WITH SiteID
# In /config/settings.ini.cfm, set indexfileinurls to 0   
# and reload the Mura application
#RewriteRule ^([a-zA-Z0-9_\-]{1,})/(.*) /$1/index.cfm/$2 [NC,QSA,PT]
 
# OPTION 3 :: Advanced Configuration
# To use the SiteID in the URL for SPECIFIC SITES ONLY, but not for all sites:
# First, add a custom getURLStem() method to the Site's contentRenderer.cfc,
# then ENABLE OPTION 1 above, adding a custom rewrite rule for each site:
#RewriteRule ^YourSiteID/(.*) /YourSiteID/index.cfm/$1 [NC,QSA,PT]
 
# 404 :: Redirect to 404.cfm with the requested URI as a query string 
# This assumes a custom file named 404.cfm exists in your root directory
#RewriteRule (.*) 404.cfm?%{REQUEST_URI}?%{QUERY_STRING}
 
# Forbid executable files from being downloaded
RewriteRule \.exe - [F]
</IfModule>
 
# -------------------------------------------------------------------------------
# UTF-8 encoding
# -------------------------------------------------------------------------------
 
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
 
# Force UTF-8 for a number of file formats
AddCharset utf-8 .css .js .xml .json .rss .atom
 
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
Windows (Web.config)
<?xml version="1.0" encoding="UTF-8"?>
 
  <!-- REQUIREMENTS:
      - IIS 7 or greater
      - Removing 'index.cfm' requires IIS URL Rewrite Module 2.0 (http://www.iis.net/download/URLRewrite)
  -->
 
  <!-- AVAILABLE OPTIONS:
     Rule 1: index.cfm and siteid in URL disabled
     Rule 2: index.cfm in URL disabled
     SEO Rules: allow for separate sitemap and robots files per site
   -->   
 
   <!-- USAGE:
      - Rename this document to "web.config" (without the quotation marks) 
        or copy the <rewrite><rules> section below into your working web.config
      - Enable the rewrite options below by changing the enabled value to "true"
      - Edit /config/settings.ini.cfm as noted in the comments before each rule
      - Reload Mura CMS
  -->
 
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
 
       <!--
          Rule 1: URLs without SiteID or index.cfm
          Usage:
            - set enabled="true" below
            - set Mura CMS Rule 2 to enabled="false"
            - set these values in /config/settings.ini.cfm:
              siteidinurls=0
              indexfileinurls=0
            - reload Mura CMS
        -->
        <rule name="Mura CMS Rule 1: siteid and index.cfm" enabled="true">
          <match url="^(.*)" ignoreCase="true" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.cfm/{R:1}" appendQueryString="true" />
        </rule> 
 
        <!--
          Rule 2: URLs without index.cfm 
          Usage:
            - set enabled="true" below
            - set Mura CMS Rule 1 to enabled="false"
            - set these values in /config/settings.ini.cfm:
              siteidinurls=1
              indexfileinurls=0
            - reload Mura CMS
        -->
        <rule name="Mura CMS Rule 2: index.cfm" enabled="false">
          <match url="^([a-zA-Z0-9_\-]{1,})/(.*)" ignoreCase="true" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{QUERY_STRING}" pattern="(hash)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/{R:1}/index.cfm/{R:2}" appendQueryString="true" />
        </rule>
 
        <!--
          SEO Rules: individual sitemap.xml and/or robots.txt for each site
          Recommended for use with Meld Google Sitemaps Plugin
          Usage:
            - set enabled="true" below
            - duplicate and rename rules for each site
            - replace www.domain.com and /siteID/ in each rule
        -->
 
        <rule name="Mura CMS SEO: Sitemap" stopProcessing="true" enabled="false">
          <match url="^sitemap.xml$" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^www.domain.com$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="/siteID/sitemap.xml" />
        </rule>
 
        <rule name="Mura CMS SEO: Robots" stopProcessing="true" enabled="false">
          <match url="^robots.txt$" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^www.domain.com$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="/siteID/robots.txt" />
        </rule>
 
      </rules>
    </rewrite>
 
    <defaultDocument>
      <files>
        <remove value="index.cfm" />
        <add value="index.cfm" />
      </files>
    </defaultDocument>
 
    <staticContent>
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/octet-stream" />
    </staticContent>
 
  </system.webServer>
</configuration>

WordPress

To enable permalinks within WordPress:

  1. Login to your WordPress dashboard
  2. Hover over Settings on the menu
  3. Choose Permalinks from the menu that appears
  4. Choose one of the available permalink structures
  5. Click the Save Changes button

Wordpress-rewrite-01.png Wordpress-rewrite-02.png Wordpress-rewrite-03.png

Linux (.htaccess)

This file is generated by WordPress automatically when Permalinks are enabled using the instructions above. It is provided here for reference.

# Wordpress permalinks
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

Windows (web.config)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Permalinks - Homepage" stopProcessing="true">
                    <match url="^index\.php$" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Permalinks - All Requests" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>