htaccess RewriteRule vs Redirect

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jackstringer
Forum Members
Forum Members
Posts: 42
Joined: Sun May 02, 2010 3:54 pm

htaccess RewriteRule vs Redirect

Post by jackstringer »

I have just placed CMSMS on a long-standing hand coded site. I have setup various Redirects but I am not sure its the best way to do it. I have some URL Rewrites but they seem not to work even though they should.

I would like to redirect to the pretty URL but that doesn't seem to work so I am going via page=alias which isn't as neat as I would like.

Any advice on how best to do this I would be grateful.

I have CMSMS 2.1.6 with pretty URLS already running.

Example of my redirects,

Code: Select all

# Main page redirects
Redirect 301 /home.php http://www.wessex4x4response.org.uk/?page=home
Redirect 301 /docs/about_us http://www.wessex4x4response.org.uk/?page=about-us
Example of the URL Rewrite that isn't working.

Code: Select all

# ------------------------------------------
# REWRITE REQUESTS TO ROBOTS.TXT AND SIMILAR
# Rewrite well-known URIs to /.well-known/ folder so that
# we can store e.g. "robots.txt" in "/.well-known/robots.txt".
# The "/.well-known/" prefix comes from RFC 5785

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

# Files that do exist (at the root) won't be rewritten
RewriteCond %{REQUEST_FILENAME} !-f

# Some very common, then less common "well-known" patterns
RewriteCond %{REQUEST_URI} =/favicon.ico [OR]
RewriteCond %{REQUEST_URI} =/robots.txt [OR]
RewriteCond %{REQUEST_URI} =/crossdomain.xml [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon.png [OR]
RewriteCond %{REQUEST_URI} =/android-chrome-192x192.png [OR]
RewriteCond %{REQUEST_URI} =/android-chrome-512x512.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-114x114-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-114x114.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-120x120-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-120x120.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-144x144-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-144x144.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-152x152-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-152x152.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-180x180-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-180x180.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-57x57-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-57x57.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-60x60-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-60x60.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-72x72-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-72x72.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-76x76-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-76x76.png [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon.png [OR]
RewriteCond %{REQUEST_URI} =/browserconfig.xml [OR]
RewriteCond %{REQUEST_URI} =/favicon-16x16.png [OR]
RewriteCond %{REQUEST_URI} =/favicon-32x32.png [OR]
RewriteCond %{REQUEST_URI} =/favicon.jpg [OR]
RewriteCond %{REQUEST_URI} =/manifest.json [OR]
RewriteCond %{REQUEST_URI} =/mstile-150x150.png [OR]
RewriteCond %{REQUEST_URI} =/mstile-310x150.png [OR]
RewriteCond %{REQUEST_URI} =/mstile-310x310.png [OR]
RewriteCond %{REQUEST_URI} =/mstile-70x70.png [OR]
RewriteCond %{REQUEST_URI} =/safari-pinned-tab.svg [OR]
RewriteCond %{REQUEST_URI} =/apple-touch-icon-precomposed.png [OR]
RewriteCond %{REQUEST_URI} =/sitemap.xml [OR]
RewriteCond %{REQUEST_URI} =/foaf.rdf [OR]
RewriteCond %{REQUEST_URI} =/w3c/p3p.xml [OR]
RewriteCond %{REQUEST_URI} ^/google[\da-f]{16}\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/y_key_[\da-f]{16}\.html$ [OR]
RewriteCond %{REQUEST_URI} =/BingSiteAuth.xml$ [OR]
RewriteCond %{REQUEST_URI} =/myopenid-hosted-verification.html [OR]
RewriteCond %{REQUEST_URI} =/humans.txt

# To further limit possible issues (e.g. if you mess up the conditions above),
# we only match files at the root, not folders or files in subfolders
RewriteRule ^([a-z0-9\-\._]+)$ /.well-known/$1 [L,NC]

</IfModule>
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: htaccess RewriteRule vs Redirect

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “The Lounge”