We changed our privacy policy. Read more.

Hot answers tagged

26

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 course and will happily sell you new certs, continuing their extremely shady pattern of behaviour. At this point all I can recommend is damage control by ...


18

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. (link) In Apache 2.4 you should do <Directory /var/www/ncp-web/> Require host localhost Require ip 127.0.0.1 Require ip 192.168 Require ip 10 &...


15

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 127.0.0.1 ::1 Allow from localhost Allow from 192.168 Allow from 10 Satisfy Any </Directory> The <Directory></Directory> statement ...


14

For wamp 2.5 on Windows, use a text editor, e.g. notepad++ to edit c:\wamp\bin\apache\apache2.4.9\conf\httpd.conf Change DocumentRoot "c:/wamp/www" to DocumentRoot "c:/my/new/path" (Note slash direction). This will change the location where files are served from (~Line 230). Change <Directory "c:/wamp/www"> to <Directory "c:/my/new/path"> (Note ...


13

If your website is down for a month, you will lose all your rankings and it may take you months to gain them back. I had a website go offline for about 3 months due to an issue with hosting. When I got it back online, it took nearly a full year to get back the rankings that it had once enjoyed. The best idea I have to mitigate the damage would be to use ...


13

You can serve a different robots.txt file based on the subdomain through which the site has been accessed. One way of doing this on Apache is by internally rewriting the URL using mod_rewrite in .htaccess. Something like: RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC] RewriteRule ^robots\.txt$ robots-disallow.txt [L] The above ...


12

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 type for your XML. That's it. The code below is a basic script for generating a dynamic XML sitemap. Please not this is only an example intended to point you, ...


12

I found the solution. Without HSTS (single redirect): RewriteCond %{HTTP_HOST} !^www\. RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] With HSTS (double redirect): RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ...


11

Not being able to find your JavaScript and CSS files is a client-side/browser issue related to your URL-path, it's not something that should be fixed in .htaccess (at least not in this case) - although it is because you are changing this URL-path (in .htaccess) that you are experiencing this problem. This problem is caused by using relative URLs in your HTML....


11

...in case the webhoster disabled the use of .htaccess files? If the webhost has disabled the use of .htaccess files then there is no direct alternative. (.htaccess = per-directory Apache config file) .htaccess files are not necessary if you have access to the Apache server config. In fact, it is preferable to use the server config instead of .htaccess ...


10

That means that the visitor did not send a referrer for the request. That can happen if: The user was a "direct" visitor and typed the URL into the browser bar or used a bookmark. The user followed a link from outside the browser (for example from an email or mobile app.) The user came to your non-secure http site from a secure https site and the browser ...


9

For use, AddOutputFilterByType should also activate the filter module. Uncomment LoadModule filter_module modules/mod_filter.so in the httpd.conf file


9

You need to drop the 'http:' prefix from all image (and any other) links on your site. When you do so, your browser will default to whatever protocol the page loads with. For example this is best: <a href="//www.example.com/"> And this is not: <a href="http://www.example.com/"> The top example is perfectly valid markup and you will load all ...


9

For your first two rewrites (non-www → www, http → https), the following rule should work: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !=www.example.com [NC] RewriteRule ^(.*) https://www.example.com/$1 [NS,L,R=permanent] Just replace www.example.com with the actual canonical hostname of your site. As for your third ...


9

Just as a matter of explanation for future users. Your 000-default.conf file is a catch-all site and should be left alone. It is good for security. It can be frustrating when a site configuration does not work and the default site is served. I get it. Still, leave it alone. Many people are unaware of why the default site exists. Here is a bit of an ...


9

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 virtual host in a separate config file and include all without having to modify your main config file: Include conf/extra/vhosts/*.conf Reference: https://...


9

Is it bad practice to force html to be read as php? Are there possible SEO repercussions for doing so? Search engines don't know nor care about how your pages are generated. They only see the output the request URL provides (in other words the output of your PHP file). Should I forgo file extensions altogether and move into a folder structure? ( .com/...


8

I recently happened across this issue myself. There is a difference between using RewriteRule in the VirtualHost and as part of an .htaccess file. The following rule will match (with a URL like this: example.com/fruit/apple) if it appears in a .htaccess file: RewriteRule ^(fruit|fruits)/apple http://newfruitwebsite.com$1 [R=301,L] but will not match in ...


8

This feature of Apache is known as "MultiViews" and it is handled by the content negotiation module: ...if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-...


8

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 February would be the earliest time frame, so not in time to help my certs that expire in two weeks. :-( To: Stephen Ostermiller, This electronic mail ...


8

No, most of the time, checking for mod_rewrite is not necessary. In fact, it is often preferable to remove this check. If the mod_rewrite directives are required by your site then you should not wrap them in a <IfModule mod_rewrite.c> container. Because if they are required and mod_rewrite is not available then the directives simply fail silently and ...


7

To enable Deflate compression for resources with WAMP (thus Apache), you can use this following code in your .htaccess file: <IfModule mod_deflate.c> <FilesMatch "\.(html|php|txt|xml|js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> It works well for several websites I own.


7

You can use these three rewrite rules which handle up to 3 levels of directories: RewriteEngine on RewriteRule ^main\/([^\/]+)\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2&var3=$3 [L] RewriteRule ^main\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2 [L] RewriteRule ^main\/([^\/]+)\/? /parser.php?var1=$1 [L] In those regular ...


7

Empty Virtual Host With virtual hosting, all traffic is routed to an IP address and then Apache matches the hostname. When virtual hosting using NameVirtualHost is enabled, the site that responds to the IP address is the first one listed in the Apache configuration file. So you can use a null virtualhost: <VirtualHost 192.168.1.1:80> ...


7

But the Official documentation clearly states it is used only for the RewriteRule directive. The docs don't say that it can only be used on the RewriteRule directive. The page you link to (which incidentally is specifically about the RewriteRule flags) simply states: Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. ...


7

The answer is in the comment: Hosting companies that offer shared accounts typically have a number of sites hosted all on the same IP address using virtual hosts as you've done.. They point the IP address either to a default server page, default site, or an error page. In either case, that does not affect any other site SEO-wise. For clarity redirecting ...


6

Click on Green Wamp Icon (Taskbar right Notification Icons) > Apache > httpd.conf > Replace all ${INSTALL_DIR}/www with your directory. Take care to use / instead of \ Click on Green Wamp Icon > Apache > httpd-vhosts.conf > Replace again the existing "www"-Directory with yours Click on Green Wamp Icon > "Restart All Services" (Tested on Windows 10, ...


6

By default the query string on the requested URL is appended to the rewritten/redirected URL. On Apache 2.4+ you should use the QSD (Query String Discard) flag on the RewriteRule directive in order to discard the query string from the redirected URL. For example: RewriteCond %{QUERY_STRING} =p=15 RewriteRule ^seasonal/christmas$ /holiday-decor/christmas....


6

Use a 302 redirect instead 301 302 Redirect Means: http://en.wikipedia.org/wiki/HTTP_302 - "The HTTP/1.0 specification (RFC 1945) defines this code, and gives it the description phrase "Moved Temporarily"." However that doesn't mean you'll be able to keep your search engine placement. It just specifies that the content is moving for a set amount of time ...


6

It might be as simple as missing one keyword that is causing your issue. ## EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 day" ExpiresByType image/jpeg "access plus 1 day" ExpiresByType image/gif "access plus 1 day" ExpiresByType image/png "access plus 1 day" ExpiresByType text/css "access plus 1 ...


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