Disable URL Rewrite for subdomain - .htaccess

I'm using Apache web server ( use .htaccess to handle URL Rewrite ).
the main domain ( e.g. example.com ) is managed by URL Rewrite generated by WordPress. The URL Rewrite applies for whole domain , including sub-domains.
I have a new subdomain called http://static.example.com, which acts a URL forward to another external URL, e.g. forward to http://www.google.com. That's :
http://static.example.com/style.css will forward to http://www.google.com/css/some_path/style.css
However, the URL Rewrite blocks it, and reports file not found, as it cannot find the /css/style.css in local server. My question is: How to disable URL Rewrite for subdomain ?
The current .htaccess is as follow:
RewriteEngine on
AddType application/rss+xml rss
AddType application/x-java-jnlp-file jnlp
Options All -Indexes
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?$ "http\:\/\/example\.com" [R=301,L]
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
<FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^static\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.static\.example\.com$
RewriteRule ^/?$ "https\:\/\/google\.com\/css\/some_path\/" [R=301,L]
Note: note that the forwarding is actually included above.
p.s. all URLs are fake.

replace
RewriteCond %{HTTP_HOST} ^static\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.static\.example\.com$
RewriteRule ^/?$ "https\:\/\/google\.com\/css\/some_path\/" [R=301,L]
with
RewriteCond %{HTTP_HOST} ^(www\.)?static\.example\.com$
RewriteRule ^(.*)$ https://google.com/css/some_path/$1 [R=301,L]
the whole htaccess would be: (adjusted)
RewriteEngine on
AddType application/rss+xml rss
AddType application/x-java-jnlp-file jnlp
Options All -Indexes
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
<FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.11"
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# redirect www.example.com/some to example.com/some
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?static\.example\.com$
RewriteRule ^(.*)$ https://google.com/css/some_path/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Related

htaccess to protect download folder

I added the following lines in the htaccess file in my download directory -
order Deny,Allow
Deny from all
Now I want to rewrite all URL from,
https://example.com/download/myfile.pdf
to
https://example.com/get-file.php?directory=download&request=myfile.pdf
Following is my htaccess file in web root -
RewriteEngine On
RewriteBase "/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
RewriteRule ^download/([A-Za-z0-9-.]*+)/?$ get-file.php?directory=download&request=$1 [NC,L]
ErrorDocument 404 /invalid-page-name
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
This does not work. Please can anyone tell me where I am making mistake? Many thanks for your help.
Please try to change
order Deny,Allow
Deny from all
to
<FilesMatch ".*">
Order Allow,Deny
Deny from All
</FilesMatch>

.htacces set 410 gone to com_k2 links

I'm trying to make a 410 (gone) to all com_k2 links that for some reason are pointing towards my site, but the WordPress part of htaccess (I mean # BEGIN WordPress - # END WordPress) overrides it and I can't make it work.
This is what I have at the top of site:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www.mypage.com
RewriteCond %{QUERY_STRING} com_k2 [NC]
RewriteRule ^ - [G,L]
then at the bottom WP makes this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The pattern is this:
https://www.mypage.com/?option=com_k2&view=itemlist&task=user&id=5640
I'm no htaccess expert so... help!
This is the full htaccess:
# BEGIN WpFastestCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mitza\.es
RewriteCond %{QUERY_STRING} com_k2 [NC]
RewriteRule ^ - [G]
# Start WPFC Exclude
# End WPFC Exclude
# Start_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=mitza#mitza.es
# End_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP_HOST} ^www.mitza.es
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WhatsApp|Mediatoolkitbot)
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !comment_author_
RewriteCond %{HTTP:Cookie} !wp_woocommerce_session
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /home/mitzaes/public_html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "index\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
AddType application/font-woff2 .woff2
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/webp A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/font-woff2 A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=2592000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN Brute Force Login Protection
<FilesMatch ".*\.(php|html?|css|js|jpe?g|png|gif)$">
order deny,allow
deny from 91.200.12.22
deny from 91.200.12.91
deny from 2607:f298:5:101b::61e:49ae
</FilesMatch>
# END Brute Force Login Protection
RewriteEngine on
Redirect 301 /nuevo-nicehash-miner-legacy https://www.mitza.es/noticias/nuevo-nicehash-miner-legacy
Redirect 301 /secciones/bitcoin/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /secciones/litecoin/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/gibson-guitars/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/nex7-workspace/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /how-videos-can-help-promote-your-business/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /working-like-a-workaholic/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/focus-lab/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/outdoor-photoshoot/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /portfolio/l-a-p-d-1947/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /audio-post/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /perfect-sunday-morning-ride/ https://www.mitza.es/zonas/paginas-web-valdemoro
Redirect 301 /secciones/noticias/ https://www.mitza.es/noticias
#2
Redirect 301 /logic-will-get-you-from-a-to-b/ https://www.mitza.es/
Redirect 301 /component/content/article/2-uncategorised/80-para-costi https://www.mitza.es
Redirect 301 /role-of-size-in-logo-design/ https://www.mitza.es/
Redirect 301 /portfolio/its-summer-time/ https://www.mitza.es/
Redirect 301 /portfolio/maybe-one-day-fashion/ https://www.mitza.es/
Redirect 301 /hello-world-2/ https://www.mitza.es/
Redirect 301 /hola-mundo/ https://www.mitza.es/
Redirect 301 /try-me https://www.mitza.es/
Redirect 301 /poze-cu-elsa https://www.mitza.es/
Redirect 301 /portfolio/sea-side-store/ https://www.mitza.es/
Redirect 301 /portfolio/time-is-nothing/ https://www.mitza.es/
Redirect 301 /category/noticias https://www.mitza.es/
# BEGIN WP Performance Score Booster Settings
# END WP Performance Score Booster Settings
Redirect 301 /case-study-envato-website-redesign/ https://www.mitza.es/
# This line :
RewriteCond %{HTTP_HOST} ^www.mypage.com
You should escape spacial character like this :
RewriteCond %{HTTP_HOST} ^www\.mypage\.com
If you want to match both www or non-www replace with this :
RewriteCond %{HTTP_HOST} ^(www\.)?mypage\.com

code editing on .htaccess file to point to https

Regarding .htaccess file, what do i have to edit on the htaccess code to always direct to the https?
I have read other Q/A but my code seems to be larger than those
My website is on wordpress
DirectoryIndex index.php
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Using my website to replace example.com/yourdomain.com
The code to do so for the .htaccess file is:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^typrograms\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.typrograms.com/$1 [R,L]
Just look for code similar to this. If you don't see it, add it right underneath the RewriteEngine On
Just a little side note:Make sure your website supports HTTPS first! It won't work otherwise.
I think the code needs to go at top of page. (Above first # at-least)

need to re-write a specific link with mod-rewrite

/support-category/?category=category name
to:
/support/category/category name
This does not appear to be working:
RewriteRule ^support/category/$4 support-category/?category=$4 [nc]
Thank you :)
Also if I am getting the category name with a get request will that work when the link is accessed via the /support/category/category name format?
here's the entire .hatacces folder and it is located in the root directory of the site.
AuthName "Restricted Area"
AuthType Basic
AuthUserFile "/var/www/vhosts/xxx.de/dev.xxx.de/.htpasswd"
Require valid-user
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC CDN
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
# END W3TC CDN
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^support/category/([^/]+)$ support-category/?category=$1 [L,QSA,NC]
</IfModule>
# END WordPress
added this to functions.php
function rewrite_support() {
$wp_rewrite->flush_rules();
add_rewrite_rule('^support/category/([^/]+)/?$','support-category/?category=$matches[1]','top');
}
add_action( 'init', 'rewrite_support');
thanks
You can use:
RewriteEngine On
RewriteRule ^support/category/([^/]+)$ support-category/?category=$1 [L,QSA,NC]

Redirect non-www to www in subdirectory

I have a .htaccess file in the http://www.mysite.com/test/ that I am trying to use to send anyone accessing http://mysite.com/test/ to http://www.mysite.com/test/ but it's no working, here's my code:
# Force Caching
Header unset Pragma
FileETag None
Header unset ETag
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|pdf|flv|mp3)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 14 days"
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
# Enable gzip compression
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
# Main Rewrite rules
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
# Always use www.
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any ideas on how to fix this?
The .htaccess file is in the /test directory. This is why the /test/ prefix is removed in the RewriteRule's request URL pattern .*. To redirect the request properly, you must change the substitution to
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]

Resources