Hot answers tagged

32 votes
Accepted

How to enable use of .htaccess in Apache on Ubuntu?

First Step Open file as sudo vim /etc/apache2/apache2.conf Second Step remove comment sign (#) if you find it before this line ( line number 187 approx.) AccessFileName .htaccess Third Step ...
user avatar
  • 436
26 votes
Accepted

StartSSL certificate gives SEC_ERROR_REVOKED_CERTIFICATE in Firefox and ERR_CERT_AUTHORITY_INVALID in Chrome

I have some bad news for you. StartSSL's certificates are no longer trusted by Chrome, Firefox, and soon other browsers, beginning with newly issued certificates first. StartSSL won't tell you this of ...
user avatar
  • 2,241
24 votes
Accepted

HTTP Status Code: Response with 101 or 301?

The correct status code to use here is without a doubt 301 Moved Permanently. 101 Switching Protocols is an internal status code that a server generally uses to automatically negotiate certain types ...
user avatar
19 votes

Setting X-Forwarded-Proto under Apache 2.4

It's correct to set this directive like RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS} If it doesn't work, you may need to install and ...
user avatar
  • 191
18 votes

Allowing access to an Apache virtual host from the local network only

People landing in this answer, please note that this is specific for Apache 2.2. Apache 2.4 has deprecated these directives. The new way is using the module mod_authz_host and the Require directives....
user avatar
15 votes
Accepted

Allowing access to an Apache virtual host from the local network only

Easy. Just set something like this within your main configuration or your virtual configuration: <Directory /var/www/path/to/your/web/documents> Order Deny,Allow Deny from all Allow from ...
user avatar
13 votes
Accepted

.htaccess syntax multiple RewriteEngine on

Does the order of the code snippets play a role? Is it correct in the above example? Yes, the order of the directives in Apache config (.htaccess) files can be important. In fact, simply having ...
user avatar
  • 41.2k
12 votes
Accepted

Make Google index over 90,000 user profiles

Sitemaps can be dynamic just like web pages. Just have a PHP script grab those names from the database and make a loop to echo out the XML for each one. Also, make sure you output the proper content ...
user avatar
  • 85.8k
12 votes

HTTP Status Code: Response with 101 or 301?

No - 101 Switching Protocols is not appropriate for redirecting to HTTPS, as this status indicates that the current connection should be upgraded to the new protocol, whereas a redirect instructs the ...
user avatar
  • 221
9 votes
Accepted

CheckCaseOnly doesn't work, while CheckSpelling does

Here is the mod_speling documentation. The CheckCaseOnly directive does not enable the module on its own. You would need to both turn on mod_speling and also put in the check case only directive: ...
user avatar
9 votes
Accepted

Possible to split virtual host definitions into multiple apache conf files?

You can use the Include directive to include other config files and split up your main config. # Virtual hosts Include conf/extra/httpd-vhosts.conf You can also use wildcards, so you can have each ...
user avatar
  • 41.2k
8 votes

How to enable use of .htaccess in Apache on Ubuntu?

Activate ModRewrite: sudo a2enmod rewrite sudo /etc/init.d/apache2 restart
user avatar
8 votes

StartSSL certificate gives SEC_ERROR_REVOKED_CERTIFICATE in Firefox and ERR_CERT_AUTHORITY_INVALID in Chrome

StartSSL confirmed that this is because of the partially revoked StartCom root certificate. They are working on getting their root certificate fully trusted by browsers again. It sounds like end of ...
user avatar
6 votes
Accepted

How to set the Content-Type for SVG files parsed by PHP

I ended up setting the handler for SVG files to application/x-httpd-php, and used apache's mod_headers to pass the correct content-type header. <Files "*.svg"> SetHandler application/x-httpd-...
user avatar
6 votes
Accepted

When does Apache log to access.log - before or after serving the request?

Apache writes to the log file after the request has been completed. It is able to remember the time that the request was started and write this time into the log file after the request was finished. ...
user avatar
6 votes
Accepted

SSL not working on home page

The problem is because you have some of the images hard-coded to load through http protocol on your index page. You should change the links to be protocol-agnostic by using //, e.g.: <img src="...
user avatar
  • 1,274
5 votes

Allowing access to an Apache virtual host from the local network only

Add this section inside your virtual host directive: <Location /mypathurl> Order deny,allow Deny from all Allow from 192.168.1.10 </Location> Replace your IP above. This ...
user avatar
  • 502
5 votes
Accepted

Updated Apache from 2.2 to 2.4 and now my sub domains are broken

One of the biggest changes from Apache 2.2 to 2.4 is the way that permissions for directories are granted. The allow from and deny from syntax is now deprecated in favor of the new require syntax. ...
user avatar
5 votes
Accepted

Can't access website from same network

After much research, I found this article on the Comcast forums: http://forums.comcast.com/t5/Home-Networking-Router-WiFi/SMCD3G-Can-t-access-web-server-from-LAN-from-Internet-OK/m-p/1754823#M55009 ...
user avatar
  • 201
5 votes
Accepted

Which is more SEO friendly, redirect or rewrite?

It generally makes little difference. A 301 redirect may cause a short term drop in ranking, but nothing to worry about. An internal rewrite keeps the same URLs. You just need to be careful that you ...
user avatar
  • 1,580
5 votes
Accepted

Leverage Browser Caching for third party resources

As @TimFountain says, you have "no control" over resources served from a third party. The request goes to the third party server, not your server - so any code you place on your server is ...
user avatar
  • 41.2k
5 votes
Accepted

HTTP2 is enabled and working, but PHP $_SERVER['SERVER_PROTOCOL'] still says "HTTP/1.1"

This has to do with how Cloudflare connects to servers. Although it does serve the client via HTTP2 (or HTTP3), it still connects to the server itself via HTTP1.1. Cloudflare only uses HTTP/1.x ...
user avatar
4 votes

Restrict mod_pagespeed to specific domains on a server

After a little digging and playing around with this, I've managed to figure it out and now have a working scenario for mod_pagespeed to only work on specific domains (vhosts) on the same server. My ...
user avatar
  • 5,032
4 votes
Accepted

apache virtual hosts on LAN

Your attempting to access the site using a IP address when your virtual host file is setup to use a domain name, not an IP address... so it'll throw up the default folder, in this case /var/www/html/. ...
user avatar
  • 32.6k
4 votes
Accepted

CSP3 Report-To header implementation

There are examples in the draft of the Reporting-Endpoints directive: Reporting-Endpoints = endpoint-1="https://example.com/reports" Your rule is correctly created, as in it returns a valid ...
user avatar
  • 210
4 votes
Accepted

SSL Labs Cipher Strength < 100%, why? How do I make it?

The picture basically depicts two things: All ciphers listed in SSLCipherSuite in your Apache2 configuration, which are defined as RSA+*, in my case I had RSA+AESGCM256:RSA+AES256:RSA+AES defined, ...
user avatar
4 votes
Accepted

Configuring .htaccess to block every request what not image in specified folder and subfolders

I would use mod_rewrite and put this in your main .htaccess near the top, just below RewriteEngine On: RewriteCond %{REQUEST_URI} ^/u/.* RewriteRule !\.(png|jpg|jpeg|gif|svg)$ - [R=404,L] Using a ...
user avatar
3 votes
Accepted

RewriteRule not working at server level?

You need to add RewriteOptions Inherit to each virtual server. Reference: http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriteoptions
user avatar
3 votes

Verify 2 cookies with mod_rewrite before serving images

but I'm not sure, if the above RewriteCond's act as X and (Y or Z) or (X and Y) or Z In the directives you posted it is the former: X and (Y or Z) However, as mentioned in my comment above, it is ...
user avatar
  • 41.2k
3 votes
Accepted

Prevent request via IP address of server

The rule to activate this block rule in mod_security can be found in: base_rules/modsecurity_crs_21_protocol_anomalies.conf That will block access to the website when accessed through the server ...
user avatar
  • 464

Only top scored, non community-wiki answers of a minimum length are eligible