Ultimate htaccess Redirects List

A list of useful htaccess redirects that you can easily implement on your site. Redirect removed pages Redirect deleted pages back to your site’s home page, or anywhere you want. RedirectMatch 301 /page1/?$ http://mydomain.com/ RedirectMatch 301 /page2/?$ http://mydomain.com/ If all pages share a common pattern, we can rewrite this in […]

Automatically Add Attributes to All Images in WordPress Posts

The below snippet will allow you to add an attribute to all images embedded in a WordPress post. function sumtips_image_attribute($content) { global $post; $pattern =”/<a(.*?)href=(‘|\”)(.*?).(bmp|gif|jpeg|jpg|png)(‘|\”)(.*?)>/i”; $replacement = ‘<a$1href=$2$3.$4$5 attribute=”attribute_value”‘; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter(‘the_content’, ‘sumtips_image_attribute’); Replace attribute=”attribute_value” to whatever attribute you need. Example: function sumtips_image_attribute($content) { […]

Exclude Certain Folders from htaccess Rewrite Rules

If you have an application or CMS running, you might have SEO url’s enabled through .htaccess rewrites. Now installing a second application in a subfolder on the same domain can cause 404 errors. This is because all subfolders follow the rules specified in the root htaccess file. To prevent the errors, […]

Scaleable Full Screen Background Image with CSS3

With the background-size property in CSS3, we can get a full page scaleable background image. Here’s the CSS code: html { background: url(images/background.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } Background image is centered, automatically resized according to browser size, and retains the aspect […]