<IfModule mod_rewrite.c>
# This will redirect all http urls to https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
# This will check if req is not to invalidate cache then serve it from dispatcher cache
RewriteCond %{REQUEST_URI} !^/dispatcher/invalidate.cache
RewriteRule !/eagle/check https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# Disable Debug Layout as part of Dispatcher Security
RewriteCond %{QUERY_STRING} debug=layout
RewriteRule .* /? [R,L]
# This will redirect if entered only domain name to home page.
RewriteRule "^/$" "https://%{SERVER_NAME}/en-us/home.html" [R,L]
# This will redirect if url contains only usa to home page.
RewriteRule "^/usa$" "https://%{SERVER_NAME}/en-us/home.html" [R,L]
# This will redirect if url contains only usa/home to home page.
RewriteRule "^/usa/home$" "https://%{SERVER_NAME}/en-us/home.html" [R,NE,NC,L]
# This will redirect if url starts with /ppp/ and replace /ppp/ from url with /en-us/
RewriteCond %{REQUEST_URI} ^/ppp/(.*)\.html
RewriteRule "^/ppp/(.*)\.html$" "/en-us/$1.html" [R,L]
# This will redirect if url starts with /UK/ and replace /UK/ from url with /en-UK/
RewriteCond %{REQUEST_URI} !^/UK/(.*)\.html
RewriteRule "^/UK/(.*)" "/en-UK/$1" [PT,NC]
# remove any trailing slash, if it's there.
RewriteRule ^(.+)/$ $1
#Shorten the URL
RewriteRule ^/content/mysite/(.*).html$ $1.html [R,L]
#Map the root folder to the home page
RewriteRule ^/?$ en.html [R,L]
# Ignore requests to "known" AEM root paths, and prefix all others with the proper AEM prefix
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteRule ^/(.*)$ /content/mysite/$1 [PT,L]
</IfModule>
Note:
1) Use of the [R] flag causes a HTTP redirect to be issued to the browser
2) However, if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the L were used
3) By default, special characters, such as & and ?, for example, will be converted to their hexcode equivalent. Using the [NE] flag prevents that from happening.
4) Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner
5) The target (or substitution string) in a RewriteRule is assumed to be a file path, by default. The use of the [PT] flag causes it to be treated as a URI instead. That is to say, the use of the [PT] flag causes the result of the RewriteRule to be passed back through URL mapping, so that location-based mappings, such as Alias, Redirect, or ScriptAlias, for example, might have a chance to take effect.
About flag details are referred from https://httpd.apache.org/docs/2.4/rewrite/flags.html
Here you can get details of all types of flags.
No comments:
Post a Comment