Category: Webservers

Discourage HTTPS On WordPress

Recently we had a WordPress site where that used HTTPS (SSL) on the login/admin areas. But we wanted to discourage HTTPS for non-admin URL. Here are the rewrite rules that ended up using in a .htaccess file:

Read More »

Block PHP Execution With .htaccess In Folder

For a server using Plesk add the following lines to a .htaccess file to stop execution of PHP scripts in the folder:

I like to use this to protect cache and image upload folders that are writable by the web server but should not be able to execute code. As a further precaution, chown the .htaccess to root, so it can’t be overwritten by Apache or FTP, and “chattr +i” to be sure about it.

Read More »

Redirect Old URLS In .htaccess

Frequently when our clients upgrade their website, they will need URLs from the old site mapped to the new site. So for example maybe they had this URL on the old server: http://acme.com/widgets/egonomic-widget-design Maybe there are many sites on the Internet that link to this URL so they don’t want it to return a 404 error. Instead they want it to redirect to the new address of the article at: http://acme.com/smallwidgets/designing-egonomic-widgets This can be accomplished with a simple rewrite rule in the .htaccess file like this: RewriteEngine On Rewriterule ^widgets\/egonomic-widget-design$ http://acme.com/smallwidgets/designing-egonomic-widgets [R=permanent,L] Note that the RewriteRule should be on one line in the file … not wrapped over two lines. The pattern for the rewrite rule is:

Also notice that in the source pattern we escaped the slash (/) with a backslash (\). This is necessary since the slash has special meaning in a regular expression. In the above

Read More »

Install SSL Certificate – Apache / CentOS / RHEL

For this example we’ll install an SSL certificate for acme.com. The certificate authority is Network Solutions. The procedure may be different for other certificate authorities especially in how intermediate certificates are setup. Install mod_ssl if needed

Copy SSL certificate to the server – The certificate should be named after the domain name and placed in the /etc/pki/tls/certs folder. For our example the cert will be:

Copy the intermediate CA bundle to the server – The bundle should be placed in /etc/pki/tls/certs/ and named after the certificate authority. For example, GoDaddy would be “gd_bundle.crt” and Network Solutions would be “ns_bundle.crt”. Sometimes the certificate authority will provide the bundle file. Other times they will just provide a set of separate root and intermediate CA certificates. In this situation, you’ll need to create the bundle file yourself. The bundle is a text file with a series of certificates. The first certificate

Read More »

Rewrite Rule To Block User Agent

Recently we’ve seen servers being overloaded by the 80legs.com web crawler. Here’s a quick rewrite rule that can be placed in .htaccess to block 80legs:

Here’s a rule to block by user agent with Nginx:

Read More »

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.