htaccess for new image folder - apache

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.

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.

Error ModRewrite in htaccess. URL 404 Error

I want to force .php extension from htaccess, because someone changed it and now all my URLs give 404 error. Can somebody help me? If you wanna I can publish the .htaccess. I've also tried Mike solution, but everything stays without .php extension and 404 error.
Also i tried to modify it from the PHP archives but the same error appears.
# It is required for use of mod_rewrite, but may already be set by your server administrator in a way that dissallows ...
Options +FollowSymLinks
Options -MultiViews
# Redirect to .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [R=301,L]
# Mod_rewrite in use.
RewriteEngine On
# Mod_rewrite in use.
RewriteEngine On
# SEGUIMOS
Redirect 301 /si-no-queda-satisfecho-le-devolvemos-el-dinero.html https://www.academiapinto.es/otros-enlaces/si-no-queda-satisfecho-le-devolvemos-el-dinero.php
Redirect 301 /si-no-queda-satisfecho-le-devolvemos-el-dinero.php https://www.academiapinto.es/otros-enlaces/si-no-queda-satisfecho-le-devolvemos-el-dinero.php
# Redirect 301 / https://www.academiapinto.es/
#parche POLILLA
Redirect 301 /temario-Guardias-Jovenes-(Polillas).php https://www.academiapinto.es/oposiciones-de-ingreso-Colegio-Guardias-Jovenes-Duque-de-Ahumada.php
Redirect 301 /blog-academia-pinto-para-preparar-tus-oposiciones-para-la-PN.php https://www.academiapinto.es/blog/articulo-academia-pinto-para-preparar-tus-oposiciones-para-la-PN.php
Redirect 301 /blog-camino-a-baeza.php https://www.academiapinto.es/blog/articulo-camino-a-baeza.php
Redirect 301 /blog-como-seleccionar-una-buena-academia-de-oposiciones-para-guardia-civil-y-policia-nacional.php https://www.academiapinto.es/blog/articulo-como-seleccionar-una-buena-academia-de-oposiciones-para-guardia-civil-y-policia-nacional.php
Redirect 301 /blog-dime-como-estudias.php https://www.academiapinto.es/blog/articulo-dime-como-estudias.php
Redirect 301 /blog-documentacion-instancia-oposicion-ingreso-a-la-guardia-civil.php https://www.academiapinto.es/blog/articulo-documentacion-instancia-oposicion-ingreso-a-la-guardia-civil.php
Redirect 301 /blog-llego-la-hora.php https://www.academiapinto.es/blog/articulo-llego-la-hora.php
Redirect 301 /blog-primer-concurso-de-fotografia.php https://www.academiapinto.es/blog/articulo-primer-concurso-de-fotografia.php
Redirect 301 /blog-psicotecnicos-recomendaciones-necesarias.php https://www.academiapinto.es/blog/articulo-psicotecnicos-recomendaciones-necesarias.php
Redirect 301 /blog-que-no-puedes-olvidar-en-tu-examen-para-la-guardia-civil.php https://www.academiapinto.es/blog/articulo-que-no-puedes-olvidar-en-tu-examen-para-la-guardia-civil.php
Redirect 301 /blog-tecnicas-de-estudio-para-aprobar-las-oposiciones-de-gc.php https://www.academiapinto.es/blog/articulo-tecnicas-de-estudio-para-aprobar-las-oposiciones-de-gc.php
Redirect 301 /blog-tienes-la-documentacion.php https://www.academiapinto.es/blog/articulo-tienes-la-documentacion.php
Redirect 301 /noticia-Academia-Pinto-incrementa-las-horas-de-clases-online.php https://www.academiapinto.es/news/noticia-Academia-Pinto-incrementa-las-horas-de-clases-online.php
Redirect 301 /noticia-instrucciones-rellenar-instancia-ingreso-guardia-civil.php https://www.academiapinto.es/news/noticia-instrucciones-rellenar-instancia-ingreso-guardia-civil.php
Redirect 301 /noticia-oferta-curso-online-ingreso-Guardia-Civil.php https://www.academiapinto.es/news/noticia-oferta-curso-online-ingreso-Guardia-Civil.php
# las de los empleos
Redirect 301 /curso-a-distancia-ingreso-guardia-civil https://www.academiapinto.es/temario-de-ingreso-guardia-civil.php
Redirect 301 /curso-a-distancia-ingreso-policia-nacional-escala-basica.php https://www.academiapinto.es/temario-de-ingreso-a-policia-nacional-escala-basica.php
Redirect 301 /curso-a-distancia-cabo-guardia-civil.php https://www.academiapinto.es/temario-de-ascenso-a-cabo-guardia-civil.php
Redirect 301 /curso-a-distancia-cabosub-guardia-civil.php https://www.academiapinto.es/temario-de-ascenso-a-cabo-guardia-civil.php
Redirect 301 /curso-a-distancia-suboficial-guardia-civil.php https://www.academiapinto.es/temario-de-ascenso-a-suboficial-guardia-civil.php
Redirect 301 /curso-a-distancia-oficial-guardia-civil.php https://www.academiapinto.es/temario-de-ascenso-a-oficial-guardia-civil.php
# antiguas de JUAN arregladas
# ahora cambiamos por las mejoras SEO las siguientes.
Redirect 301 /clases-presenciales-de-ingreso-guardia-civil.php https://www.academiapinto.es/curso-de-ingreso-a-guardia-civil.php
Redirect 301 /clases-online-de-ingreso-guardia-civil.php https://www.academiapinto.es/curso-online-de-ingreso-a-guardia-civil.php
Redirect 301 /clases-online-de-cabo-guardia-civil.php https://www.academiapinto.es/curso-online-de-ascenso-a-cabo-guardia-civil.php
Redirect 301 /curso-online-de-cabo-guardia-civil.php https://www.academiapinto.es/curso-online-de-ascenso-a-cabo-guardia-civil.php
# seguimos.
Redirect 301 /clases-online-de-oficial-guardia-civil.php https://www.academiapinto.es/curso-online-de-ascenso-a-oficial-guardia-civil.php
Redirect 301 /clases-online-de-suboficial-guardia-civil.php https://www.academiapinto.es/curso-online-de-ascenso-a-suboficial-guardia-civil.php
Redirect 301 /clases-presenciales-de-ascenso-a-oficial-guardia-civil.php https://www.academiapinto.es/curso-de-ascenso-a-oficial-guardia-civil.php
Redirect 301 /clases-presenciales-de-ascenso-a-suboficial-guardia-civil.php https://www.academiapinto.es/curso-de-ascenso-a-suboficial-guardia-civil.php
Redirect 301 /temario-Prueba-Conocimientos-Guardias-Jovenes-(Polillas).php https://www.academiapinto.es/temario-Guardias-Jovenes-(Polillas).php
#parche NO-CNP
Redirect 301 /curso-a-distancia-guardia-civil-y-policia-nacional.php https://www.academiapinto.es/curso-online-de-ingreso-a-guardia-civil.php
Redirect 301 /temario-Guardias-Jovenes-(Polillas).php https://www.academiapinto.es/temario-Guardias-Jovenes-(Polillas).php
# using root, not index.php ...
# RewriteRule ^index\.php$ https://www.academiapinto.es/ [L,R=301]
# RewriteRule ^index\.htm$ https://www.academiapinto.es/ [L,R=301]
# RewriteRule ^index\.html$ https://www.academiapinto.es/ [L,R=301]
RewriteRule ^/temario-de-ingreso-guardia-civil$ https://www.academiapinto.es/temario-de-ingreso-guardia-civil.php [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
# ... seguridades varias que interesan ...
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn´t directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn´t directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
# ... check for parameters ...
# RewriteRule ^([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)$ /index.php [L]
# RewriteRule ^([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)$ /index.php [L]
# RewriteRule ^([A-Za-z0-9_]+)/([A-Za-z0-9_]+)$ /index.php [L]
# RewriteRule ^([A-Za-z0-9_]+)$ /index.php [L]
# --- #RewriteRule ^(.*) /index.php?p1=ERROR_MODRW_ACCESS [L]
##############################################################
# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 7200 seconds"
ExpiresByType image/gif "access plus 2678400 seconds"
ExpiresByType image/jpeg "access plus 2678400 seconds"
ExpiresByType image/png "access plus 2678400 seconds"
ExpiresByType text/css "access plus 518400 seconds"
ExpiresByType text/javascript "access plus 2678400 seconds"
ExpiresByType application/x-javascript "access plus 2678400 seconds"
</ifmodule>
# Cache Headers
<ifmodule mod_headers.c>
# Cache specified files for 31 days 2678400
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
# Cache HTML files for a couple hours 7200
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
# Cache PDFs for a day 86400
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
# Cache Javascripts for 31 days 2678400
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</ifmodule>
##############################################################
Thanks, i'm really desperated with this one.

What is missing or wrong with my .htaccess file?

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.

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

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.