What is missing or wrong with my .htaccess file? - apache

I know nothing about .htaccess files so I would like to ask you guys some help. I will list the things I was trying to do with code and that is not working.
Remove .html and .php from my url (get a clean link I mean);
Compress files like images and .js/.css (Google speedtest says it is not happening);
Make the website works with and without www (standard would be without www);
Well that's it. Thank you in advance for you help!!
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<FilesMatch "(\. (engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)? |xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
Options -Indexes
RewriteEngine on
RewriteRule ^/abc/(.*)$ /new/$1 [R=301,L]
RewriteEngine on
RewriteRule ^/def/(.*)\.html$ /new2/$1.html [R=301,L]
RewriteEngine on
RewriteRule ^/ghi/(.*)\.(html|htm)$ /new3/$1.$2 [R=301,L]
RewriteEngine on
RewriteRule ^/jkl/(.*)$ http://www.mywebsite.com/$1 [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>

To get automatic redirection in Apache you can consider using MultiViews, which is easy to enable and backwards-compatible. For example, with this one line in your .htaccess file:
Options +MultiViews
You can now access the same file from these URLs:
/def/search.html
/def/search
After that it's a matter of changing the HTML files so they link to the URLs without the file suffix. This is a significant undertaking (but there are some tools that might help).
As for the gzip attempt, others on StackOverflow seem to recommend mod_deflate in preference to mod_gzip as it is easier to configure. See this page for instructions on using mod_deflate (just below the mod_gzip instructions).
Finally, you can use mod_rewrite to redirect to the canonical URL without the www prefix. Example for www.example.com:
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^/(.*) http://example.com/$1 [L,R=301]

Why not use a file like here:
GitHub - Apache Server Configs
This .htaccess already has configurations for compression etc.
I think that you will be able to add to the file everything that need for you for example you can add type of flashplayer's files.

Related

Rewrite URL without Redirect in .htaccess

I would like to rewrite some of my paths on my website. I don't want to redirect, just simply modify the URLS. This is what I have attempted so far based on this answer:
RewriteRule ^thankyou.html /thankyou/$1 [L]
However, all this is doing is redirecting to my homepage. I have several paths I would like to rewrite globally. But I figured I would test it first on my /thankyou.html page to get it working. So in this example, I am just trying to rewrite example.com/thankyou.html to example.com/thankyou.
Here is the full .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example\.com [NC]
RewriteRule ^ https://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
RewriteRule ^thankyou.html /thankyou/$1 [L]
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/webm "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
# Others
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</IfModule>
I've done this in the past on AWS Amplify using JSON which looks like this:
[
{
"source": "https://www.example.com/thankyou.html",
"target": "https://www.example.com/thankyou",
"status": "301",
"condition": null
}
]
But unfortunately, this web app is not hosted on amplify and I am struggling to find an equivalent.
RewriteRule ^thankyou.html /thankyou/$1 [L]
If the underlying file is thankyou.html then you have the rewrite the wrong way round. You should be rewriting the request from /thankyou/ (which I assume is the intended canonical URL) to /thankyou.html. And consequently you should be requesting (linking to) the URL /thankyou/ in your HTML source.
Aside: The $1 backreference in the substitution string is superfluous. It is always empty in this example.
In other words:
RewriteRule ^thankyou/$ thankyou.html [L]
The slash prefix on the substitution string is not required for internal rewrites (and best omitted).
Note that since the URL-path also matches the file basename, you need to ensure that MultiViews (part of mod_negotiation) is also disabled, otherwise your rule is essentially bypassed (which could result in problems later). At the top of the .htaccess file you should add:
Options -MultiViews
UPDATE:
It sounds like you are expecting the URLs to magically change in the HTML source by doing the above. This is not the case and not the purpose of .htaccess. To change the URLs your users see (ie. the canonical URL), you must actually change the URLs you are linking to in the HTML source - there is no shortcut to this if this is an otherwise static site.
If the "old" URLs (ie. /thankyou.html) are established and indexed by search engines and/or linked to by external third parties then you can also include an external 301 redirect from /thankyou.html to /thankyou in order to preserve SEO. But note that this is not essential for your site to function, since you should have already changed the URLs in the underlying HTML source. It is necessary for SEO.
If you don't change the URL in the HTML source (and still implement the "redirect") then users can still "see" the old URL on the page (when they hover over or "copy" the link) and every time they click the link they are externally redirected (doubling the number of requests to the server and potentially slowing your users).
For example:
Options -MultiViews
# Redirect from "/thankyou.html" to "/thankyou" for SEO
RewriteRule ^thankyou\.html$ /thankyou [R=301,L]
# Rewrite from "/thankyou" to "/thankyou.html"
RewriteRule ^thankyou$ thankyou.html [END]
Note the addition of the END flag on the second (rewrite) rule.
Note also that I have removed the trailing slash on the URL. So, /thankyou is the URL you should be linking to and /thankyou.html is the underlying file that handles the request.

htaccess for new image folder

I'm trying to rewrite the url to another url.
because i already made a subdomain for my images and i want all the url requesting for my images should get in the new image domain.
for example.
old image link - http://www.website.com/uploaded/art/sd.jpg
should get to - http://img.website.com/uploaded/art/sd.jpg
another one
old image link - http://www.website.com/uploaded/photo/ss.jpg
should get to - http://img.website.com/uploaded/photo/ss.jpg
i have my subfolders in my uploaded folder.
here is my htaccess for now and it seems i cant get it to work.
RewriteEngine on
RewriteRule ^uploaded/(.*)$ http://img.website.com/uploaded/$1 [R=301,L]
# Use PHP5.4 as default
#AddHandler application/x-httpd-php54 .php
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L,NC]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 day"
ExpiresByType text/css "access plus 18000 seconds"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 18000 seconds"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
this htaccess is saved to my public html folder. main root of my website.
Create an htaccess in the /uploaded folder and add the following redirect :
Redirect 302 /uploaded/ http://img.website.com/uploaded/
This will redirect all requests from /uploaded folder to the new destination, eg : example.com/uploaded/foobar to http://img.website.com/uploaded/foobar .
You change the redirect status to 301 (permanent redirect) when you are sure it's working ok.

Prestashop: new domain still pointing to old url and unable to access back-end

I am in the process of cloning my shop ahead of a much dreaded prestashop upgrade (best practice here). My shop is up and running in a subfolder of my root (/.) dir (ex: mydomain.com/shop/).
I followed all the instructions given, namely:
Created a new folder in my root (/.) directory -> /newfolder/
Exported prestashop database to my hard drive
Copied all my prestashop files to my hard drive (using FTP)
Created new database and imported the local back-up
Uploaded all my files from hard drive to new folder
Updated my config/settings.inc.php with new database credentials
(Also updated config/settings.inc.old.php and config/settings.old.php just in case)
Updated the physical_uri field of my ps_shop_url table to /newfolder/
Didn't edit the DOMAIN and SSL_DOMAIN fields of ps_configuration because domain remained unchanged (ex: mydomain.com)
Even removed all files from cache/smarty/cache and cache/smarty/compile except the index.php
Removed newfolder/.htaccess
Cleared my browser cookies and cache (multiple times)
At this point I tried to connect to my new domain (ex: mydomain.com/newfolder) and I was redirected to my old url (ex: mydomain.com/shop).
I then tried to access the back-office of my new shop (ex: mydomain.com/newfolder/admin1) and when I input my credential I get redirected to the exact same log-in page with no error message whatsoever.
What am I missing guys ?
Any help appreciated,
Thanks !
C
btw:
version of Prestashop (for both folders) is 1.6.0.14
site is hosted on 1and1 servers
db are mysql 5.1 for current shop, 5.5 for clone shop
EDIT #1 :
Here is my newfolder/.htaccess :
`Options +FollowSymLinks
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
# Disable Multiviews
Options -Multiviews
RewriteEngine on
#Domain: lademo.fr
RewriteRule . - [E=REWRITEBASE:/shop/]
RewriteRule ^api$ api/ [L]
RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Images
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$">
Header add Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-otf "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
Header unset Etag
</IfModule>
FileETag none
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript font/ttf application/x-font-ttf font/otf application/x-font-otf font/opentype
</IfModule>
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /shop/index.php?controller=404
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

Allow access from subdomain

I'm making a new version of my website on a subdomain of my main site. The url of my main site is http://chirotremelo.be and my subdomain is http://v2.chirotremelo.be . My server setup is the public_html folder with within the 'old' version of the website, along with folders with images. There is also a v2 folder in this folder, containing my new version which also uses images from the standard website.
I develop my new version on my local machine, also having the v2 folder inside the main site. This is done so I can easily update it.
Now, because my v2 loads resources from the v2 version as well as the main site version, I set the <base> to http://chirotremelo.be/. To include files from the v2 folder I simply add v2/ in front of a certain url.
Locally this works nicely, but on my live version it doesn't seem to load eg http://chirotremelo.be/v2/newSite.css. The error shown is:
Imported resource from origin 'http://chirotremelo.be' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://v2.chirotremelo.be' is therefore not allowed access.
I have searched around for this but can't seem to find any solutions right away. I think it might have something to do with my .htaccess file, so here it is included:
php_value date.timezone Europe/Brussels
<FilesMatch ".php$">
AddHandler x-httpd-php54 .php
</FilesMatch>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?chirotremelo\.be/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
RewriteCond %{HTTP_HOST} ^www.chirotremelo.be [nocase]
RewriteRule ^(.*) http://chirotremelo.be/ [last,redirect=301]
I know this might not be a lot to go on but I've never worked with subdomains before. I have successfully used http://v2.chirotremelo.be/newSite.css, but it kind of needs to be with a base of the non-subdomain to load the content that is only available on the main site.
This problem called Cross-Origin-Resource-Sharing (or CORS in short). You will find many questions here facing the problem, especially for asynchronous JavaScript requests.
It is some kind of browser related issue; the server will still serve the files requested, but the browser blocks it to prevent that a site will load "bad" content from a "bad" site. You need to send a CORS-Header with your server response to let the browser allow it.
In your case (as this is not a production site), I would advise you the following solution:
You could try to add
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
</IfModule>
to your .htaccess file. (Note, this needs mod_headers in Apache to be enabled, but I guess this is enabled by default).
This is not the best solution, especially there might be more elegant ones with redirect rules. But it should work for this special case (testing/beta site).

mod_rewrite directives work on their own but not in context of full htaccess file with concrete5

I am having trouble ammending a site's htaccess file with some mod_rewrite directives I know work in isolation but not in context of the full htaccess file. The site's CMS is Concrete5, so there are some specifics for the Concrete5 configuration in the htaccess file.
I am trying to rewrite URLS of format
http://www.mywebsite.com/proplist/?location=town&distance=3&proptype=buy&maxPrice=&minPrice=&bedrooms=&propertyType=
to
http://www.mywebsite.com/property/town/buy/
I have got the following directives to work in isolation (where I created index.php in a folder called proplist under the webroot on another webserver):
RewriteBase /proplist
RewriteRule property/([a-zA-z]+)/([a-zA-z]+)/$ http://www.mywebsite.com/property/\/?location=$1&distance=3&proptype=$2&maxPrice=&minPrice=&bedrooms=&propertyType= [R]
Redirect 301 /property/ http://www.mywebsite.com/proplist/
(I guess I can use %{REQUEST_FILENAME} instead of http://www.mywebsite.com)
I can't get the above to work in the context of the htaccess file that is already in place which is (with my ammendments):
<IfModule mod_rewrite.c>
RewriteEngine On
#
# -- concrete5 urls start --
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
# -- concrete5 urls end --
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# -- rewrite property search urls --
RewriteBase /proplist
RewriteCond %{REQUEST_URI} property
RewriteRule property/([a-zA-z]+)/([a-zA-z]+)/$ http://www.mywebsite.com/proplist/\/?location=$1&distance=3&proptype=$2&maxPrice=&minPrice=&bedrooms=&propertyType= [R]
Redirect 301 /property/ %{REQUEST_FILENAME}/proplist/
RewriteBase /
# -- end rewrite property search urls --
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 week"
</IfModule>
## EXPIRES CACHING ##
AddType application/font-wof .woff
AddType application/x-font-woff .woff
AddType application/x-woff .woff
# end of full htaccess file
The result of the above is urls such as http://www.mywebsite.com/property/woking/buy/ being redirected to http://www.mywebsite.com/index.php
Can anyone help?
The first thing you need to do is place all the property search URL rules before the concrete5 routing rules. The routing rules completely mangle the URI and when a redirect happens, the mangled URI ends up getting redirected.
So that means these rules:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
must be before your CMS rules.
You also probably want to change your rules from:
# -- rewrite property search urls --
RewriteBase /proplist
RewriteCond %{REQUEST_URI} property
RewriteRule property/([a-zA-z]+)/([a-zA-z]+)/$ http://www.mywebsite.com/proplist/\/?location=$1&distance=3&proptype=$2&maxPrice=&minPrice=&bedrooms=&propertyType= [R]
Redirect 301 /property/ %{REQUEST_FILENAME}/proplist/
RewriteBase /
# -- end rewrite property search urls --
to:
# -- rewrite property search urls --
RewriteRule ^property/([a-zA-z]+)/([a-zA-z]+)/$ /proplist/?location=$1&distance=3&proptype=$2&maxPrice=&minPrice=&bedrooms=&propertyType= [L]
RewriteRule ^property/$ /proplist/ [L]
# -- end rewrite property search urls --
But I'm not really sure what the point of your original rules were. They're a mix of mod_alias and mod_rewrite which was sure to be a mess. Change the flags from [L] to [L,R=301] if you actually wanted to redirect instead of rewriting (which is what you are asking for, rewriting is not redirecting). So those 2 rules need to go right below the one that redirects to www.