Forum Moderators: phranque
i've calculated the size of the response document generated by a cgi script and sent the correct Content-Length header - it's quite doable in a script.
i always prefer to turn off any X-Powered-By headers.
"Server: Apache" is okay but i would show much more than that.
This setting applies to the entire server, and cannot be enabled or disabled on a virtualhost-by-virtualhost basis.
http://httpd.apache.org/docs/2.4/mod/core.html#servertokens
yours is the first I've seen send both those two via .htaccess rather than having to set them in PHP -- I think I've seen cache-control sent by one server before not expires or content length
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "access plus 7 days"
Isn't the content-length header supposed to be the actual size of the material being sent out? It shouldn't make any difference how the material was generated in the first place, just what the browser should be prepared to take in.
web2008, see earlier post about mod_speling.
^example\.com [NC] with !^(www\.example\.com)?$ Once you have one RewriteRule you should not use Redirect or RedirectMatch for any of the other rules. Convert all such directives to use RewriteRule.
The non-www/www redirect must be the last of the RewriteRules that redirect.
The RegEx pattern in the condition in the non-www/www redirect is non-optimum, replace ^example\.com [NC] with !^(www\.example\.com)?$
Do not specify protocol and hostname in the 404 directive, otherwise it will return a 302 response.
ErrorDocument 404 http://www.example.com/404.html
CheckSpelling Off
CheckCaseOnly On
# whenever using mod_rewrite and/or the rewrite engine, it MAY not function properly on standard shared hosting without the following line added.
Options -MultiViews
# Redirect Old File to New file permanent
RewriteRule archive/old.html company/new.html [R=301]
RewriteRule archive/old2.html company/new2.html [R=301]
# redirect only example.com to www.example.com. The non-www/www redirect must be the last of the RewriteRules that redirect.
# The "L” flag means that this is the “last” rewrite rule and to stop rewrite process.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ # turning "spell checking" off. This is on by default and will therefore load http://example.com/file.html if http://example.com/file1.html does not exist
CheckSpelling On
# enable case checking
CheckCaseOnly On
By the way what for do I need ^ character in front of folder RewriteRule ^archive. Can I use like RewriteRule /archive?
^rats/ rats/ RewriteRule /archive
RewriteRule ^archive/oldfile.html http://www.example.com/new/newfile.html [R=301,L]
or
RewriteRule /archive/oldfile.html http://www.example.com/new/newfile.html [R=301,L]
# redirect only example.com to www.example.com
# do not redirect subdomains
# The non-www/www redirect must be the last of the RewriteRules that redirect.
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301]
# redirect only example.com to www.example.com. Keep subdomain as it is.
web2008, do you have subdomains? I mean real ones, not "www."
RewriteCond %{HTTP_HOST} m\.example
RewriteCond %{HTTP_HOST} !^(m\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} (m|blog|sub1|sub2)\.example
RewriteCond %{HTTP_HOST} !^(%1\.example\.com)?$
You attempted to reach blog.example.com but instead you actually reached a server identifying itself as www.example.com. This may be cause by a misconfiguration on the server.
RewriteCond %{HTTP_HOST} blog\.example\.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule .? http://www.example.com%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
RewriteCond %{HTTP_HOST} blog\.example\.com
This has been a long thread. Did you at some point explain the physical configuration? I'm assuming
URL www.example.com/etcetera >> ordinary non-blog stuff here, based in whatever directory holds example.com
URL blog.example.com/etcetera >> blog stuff, based in a /blog/ directory (not necessarily with that name) physically located inside the example.com directory
Come to think of it, what happens if someone explicitly requests www.example.com/blog/something-here?