WarpConduit Computing

  • Quick Tips
  • Web Design & Development
  • WordPress Plugins
  • Home
  • Passphrase Generator
  • Password Generator
  • About
  • Contact

Redirecting to www with htaccess

September 25, 2009 by Josh Hartman

This is useful for SEO so all your ranking gets added to one url and not divided between two.

Use the following example to create a redirect from any incoming domain to your www sub-domain:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>

To use this method you need have mod_rewrite installed and enabled on Apache web server and you need to be able to create a custom .htaccess file.

A few things to note, the NC means that the regex is not case sensitive, R=301 means that this redirect will return an HTTP status code of 301 Permanent Redirect (search engine friendly), and the L after that means that no further rule processing should be done.

Filed Under: Web Design & Development Tagged With: htaccess, redirect

Dynamically Load CSS and JS files using PHP

May 12, 2009 by Josh Hartman

I’ve been working more and more with jQuery and plugins that go with it and it can be a pain to keep going back to the code and adding another <script> tag for each of these and then removing it again when you find out it isn’t quite what you needed.  I came up with a solution to look in a “js” folder and create the correct tags for loading the files.  Then i extended this to do CSS files as well.  All you need to do is drop js/css files into “js” and “css” directories and the page you have placed the PHP code onto will load those files.  To disable a file, just delete it or move it into a subfolder. Oh, you are worried about loading order you say?  Since readdir() lists the files in alphabetical order you can rename your files using numbers (01-jquery.js, 02-jquery-plugin.js, 03-global.js, etc.) to adjust the loading order.  If you find any issues leave a comment to help others figure it out.  Hope you find it useful in some application.

Directory Structure

css

01-style.css
02-morestyles.css
03-custom.css

js

01-jquery.min.js
02-jquery.plugin.min.js
03-custom.js

index.php

Code

Place the following code just before your document’s closing </head> tag.

' . "\n";
        }
    }
    closedir($handle);
    echo $js;
}
 
// FOR CSS FILES
$css = '';
$handle = '';
$file = '';
// open the "css" directory
if ($handle = opendir('css')) {
    // list directory contents
    while (false !== ($file = readdir($handle))) {
        // only grab file names
        if (is_file('css/' . $file)) {
            // insert HTML code for loading Javascript files
            $css .= '' . "\n";
        }
    }
    closedir($handle);
    echo $css;
}
?>

Result





Dynamically Load CSS and JS files using PHP










Hello World!

Notes

This code will not search subdirectories for files to load.  This code also doesn’t help when you are using a WYSIWYG editor such as Adobe Dreamweaver that will look for JS/CSS links in the HTML header and load the files.  These programs don’t run the PHP code and therefore don’t know what JS/CSS files are suppose to be loaded. You may need to adjust the path to the “js” and “css” directories based on the location of the page you enter the code onto.

Filed Under: Web Design & Development Tagged With: css, javascript, php

Windows 7 RC Review

May 7, 2009 by Josh Hartman

After hearing many good things about Windows 7 I went ahead and downloaded the publicly available release candidate (Build 7100) from Microsoft. To do this you first go to the Windows 7 product page and download a 2+ GB ISO file, burn a DVD, and then make a decision to upgrade (Windows Vista only) or do a clean install (format and start fresh).  I just wanted to try it out so I upgraded my Dell XPS M1710 laptop from Windows Vista Ultimate to Windows 7 Ultimate.  You’ll lose your access to Windows Vista Ultimate Extras in 7, but there wasn’t that much great stuff in there anyways.  It also told me I had to uninstall Daemon Tools, which I use for mounting CD images. It uses a virtual hardware driver to function so I think there will need to be an updated Windows 7 driver before that works.  No issues were encountered during the upgrade, and it even fixed a problem with my audio popping and clicking that I was having with my external Sound Blaster Live! 24-bit USB sound card under Vista (worked fine in XP).

Background Image Personalization

Background Image Personalization

Anyways here is my take on it so far after using it for one day.

The interface has a few changes from Vista, the taskbar has been updated with an unmarked “Show/Hide Desktop” button after the time in the lower right corner, and each program just shows as a large icon now instead of a small icon and title.  This can be changed back if desired.  The quick launch has been replaced by a program pinning feature, when you open a pinned program the icon then functions as the taskbar button to switch to/minimize the program.

The media player is updated as well, though i don’t know what features have been added.

The personalization screen has new “theme” options, and i’ve found that simply changing a background requires a little more work than before because you now have the option of choosing multiple backgrounds and having Windows automatically flip between them every 30 minutes or whatever you specify.

As expected with any OS upgrade I did have a couple programs that didn’t cooperate fully.  ClamWin AV runs fine, but Windows 7 doesn’t recognize it as a anti-virus program and sends up a flag that I don’t have anti-virus protection.  After suppressing that message and the one about the firewall being disabled Windows 7 doesn’t report any issues.  Also the Dell Quickset utility that pops up a volume control when you press the laptop’s built-in volume up/down buttons doesn’t work anymore.  The Dell Quickset utility opens and functions fine, and the volume buttons work fine, but it just doesn’t show you what volume level you are at when pressing the buttons.  These are minor issues and I’m sure their developers are working on issues just like this.

So in general I am pleased with Windows 7 and plan on upgrading to it when it goes gold.

Filed Under: Computers Tagged With: operating system, software, upgrade, windows 7

Base64 Inline Images in CSS cause Unsecure Page Warning in IE

February 25, 2009 by Josh Hartman

While working on a magento e-commerce website i found that customers were receiving the “unsecure items” warning during the checkout process.  I used various tools to find the offending item, but was unsuccesful, nothing would tell me what this “unsecure item” was. One thing that i had ignored but suspected was a reference in Firefox’s “View Page Info” window under the media tab.  The address column identified it as “data:image/gif,AAAA” and the size was “unknown” and the type was “image.”  I investigated this item further and found a reference to it inside the lightbox CSS file used as a background-image to create some workaround for an IE issue with the lightbox.  I replaced the base64 background-image reference with a spacer GIF file url, updated the magento cache and voilà, no more unsecure item warnings in IE!

Filed Under: Web Design & Development Tagged With: base64, inline images, magento

  • « Previous Page
  • 1
  • …
  • 9
  • 10
  • 11
  • 12
  • Next Page »

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • Extremely Useful Applications for Web Development and IT Tasks
  • Installing BookStack Wiki on cPanel Shared Hosting
  • Media (MIME) Type Reference List

Tags

automatic benchmark cbc cipher class comparisons cpanel credit memo css decrypt encrypt font gzip htaccess html image increment javascript jquery list magento mcrypt mysql number old opencart order php profiling random redirect repository rijndael shipment software strict ubuntu url wincachegrind windows windows 7 wordpress xampp xdebug xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2023 WarpConduit Computing. All Rights Reserved.