The .htaccess file is famous for helping us set redirects but it can also help improve our website’s loading times as well as help with some crawling and indexing issues that I will cover in a bit. Learn where the file can be found, how it compares to https.conf, how it can be used for redirects, deal with duplicate content, what performance issues it can encounter, how it can help you create custom 404 pages, how it helps you leverage browser caching, gzip, disable image hotlinking, add canonical tags and robots directives in the HTTP headers and what tools and resources can help you learn even more.
7. @RoxanaStingu
.htaccess is very powerful –
even a missing space can result
in server malfunction.
DON’T make .htaccess changes
without a proper back-up!
> Disclaimer
17. @RoxanaStingu
> .htaccess speed dating
FULL NAME Hyper Text Access
JOB Affects the folder it’s placed in
ORIENTATION Execution order is top to bottom (mostly)
LANGUAGES Directives
24. @RoxanaStingu
> RewriteRule syntax
RewriteRule Pattern Substitution [FLAGS]
Reg. expr. checked
against the
requested URI
Any of the following:
- modification to the part matched by the Pattern
- absolute path to a file
- full URL to redirect to
- a dash “-” to do nothing
Optional - All kinds
of special actions
29. @RoxanaStingu
Indexing Google stops after [3 to 5] redirects
Crawling Wastes crawl budget
Speed Each step slows down the time it takes
for a page to load
61. @RoxanaStingu
> Canonical tags
### Add a canonical tag to a non-HTML resource
<Files white-paper.pdf>
Header add Link '<https://www.example.com/white-paper-download.html>;
rel="canonical"'
</Files>
.htaccess
62. @RoxanaStingu
> Indexing directives
### Add a meta robots tag to a non-HTML resource
<Files white-paper.pdf>
Header add X-robots-tag "noindex, noarchive, nosnippet"
</Files>
### Add meta robots tags to non-HTML resources by type
<Files ".(docx|pdf)$">
Header add X-robots-tag "noindex, noarchive, nosnippet"
</Files>
.htaccess