HTML and CSS Reference
In-Depth Information
noarchive"
# <FilesMatch "\.(doc|pdf|png|jpe?g|gif)$">
# Header set X-Robots-Tag "noindex,
noarchive, nosnippet"
# </FilesMatch>
# </IfModule>
Trailing slash redirects
Search engines consider folder URLs http://example.com/foo and ht-
tp://example.com/foo/ as two different URLs and as such would consider the
content to be duplicates of each other. To prevent this, rewrite the URLs either
to change http://example.com/foo to http://example.com/foo/ or ht-
tp://example.com/foo/ to http://example.com/foo .
The way we do this is to edit the .htaccess file for Apache server and add the fol-
lowing rewrite rules (see Chapter 5 , Customizing the Apache Server , for details on
how we edit .htaccess files).
Option 1: Rewrite example.com/foo to example.com/foo/
The following code snippet helps us to rewrite example.com/foo to ex-
ample.com/foo/ :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI}
!(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
Option 2: Rewrite example.com/foo/ to example.com/foo
The following code snippet helps us to rewrite example.com/foo/ to ex-
ample.com/foo :
RewriteRule ^(.*)/$ $1 [R=301,L]
Search WWH ::




Custom Search