Forum Moderators: phranque
https://www? My current HT access file for the main site is below
RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#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
#cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
#cache css, javascript and text files for one week
<FilesMatch ".(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
#cache flash and images for one month
<FilesMatch ".(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
#disable cache for script files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
#Redirect old affiliate pages
RewriteEngine on
RewriteBase /
RewriteRule ^aff/(.*) /page.htm [R=301,L]
RewriteEngine on
RewriteBase /
RewriteRule ^idevaffiliate/(.*) /newpage.htm [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^oldpage\.htm$ "http\:\/\/www\.example\.com\/newpage\.htm" [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^JobSeekerTools\.htm$ "http\:\/\/www\.example\.com\/blog\/" [R=301,L]
Redirect 301 /page.htm http://www.example.com/page/
Redirect 301 /blog/page2/ http://www.example.com/blog/pagenew
RewriteRule ^blog/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule blog/ /blog/index.php [L]
[edited by: not2easy at 8:41 pm (utc) on Nov 25, 2016]
[edit reason] readability [/edit]
if you have your http to https redirect in the top level, that will apply all the way down unless there's a conflicting rule.
Note that rewrite configurations are not inherited by virtual hosts. This means that you need to have a RewriteEngine on directive for each virtual host in which you wish to use rewrite rules.
Do I need to edit both?
RewriteRule ^oldpage\.htm$ "http\:\/\/www\.example\.com\/newpage\.htm" [R=301,L]
Redirect 301 /page.htm http://www.example.com/page/
you cannot control the order in which different module's directives execute by specifying their order in .htaccess -- The module execution order determines that.
.htaccess rules cascade.
not sure what you mean by this
having rules apply from a parent and a child at the same time.
beware of the per-directory prefix stripping implications
The inherited rules are virtually copied to the section where this directive is being used.:: further detour to test site to confirm that "virtually copied" means just that--copied--with no supplementary cleverness involving added or removed path elements ::
The only time I use .htaccess elsewhere is for access rules.