tag:blogger.com,1999:blog-82093531698593749352024-03-13T06:53:54.503+07:00cool hakEUnknownnoreply@blogger.comBlogger17125tag:blogger.com,1999:blog-8209353169859374935.post-41081862021863737432009-08-12T00:29:00.001+07:002009-08-12T00:29:37.637+07:00.htaccess tips and tricks<div xmlns='http://www.w3.org/1999/xhtml'><h1>.htaccess tips and tricks</h1> <div class='ht-title'> <ifModule><br/> <span style='color: rgb(183, 201, 146);'> clever stuff here</span><br/> </ifModule> </div> <div class='tiny-space'> </div> <h2 id='section-introduction'>Introduction to .htaccess..</h2> This work in constant progress is some collected wisdom, stuff I've learned on the topic of .htaccess hacking, commands I've used successfully in the past, on a variety of server setups, and in most cases still do. You may have to tweak the examples some to get the desired result, though, and a reliable test server is a powerful ally, preferably one with a very similar setup to your "live" server. Okay, to begin..<br/> <br/> <div class='right-text image-title'> <small><strong>..a win32 Apache mirror of corz.org </strong></small><br/> <img title='peecee Explorer view with invisible files' alt='peecee Explorer view with invisible files' src='http://corz.org/serv/tricks/img/peecee-mirror.png'/> </div> <em><strong>.htaccess files are invisible</strong></em><br/> <br/>There's a good reason why you won't see .htaccess files on the web; almost every web server in the world is configured to ignore them, by default. Same goes for most operating systems. <a id='jump-hide-files' title='But not, entirely' href='http://corz.org/serv/tricks/htaccess.php#hide-deny-files'>Mainly</a> it's the dot "." at the start, you see?<br/> <br/> If you <em>don't</em> see, you'll need to disable your operating system's invisible file functions, or use a text editor that allows you to open hidden files, something like bbedit on the Mac platform. On windows, showing invisibles in explorer should allow any text editor to open them, and most decent editors to <em>save</em> them too<a href='http://corz.org/serv/tricks/htaccess.php#windows-invisible-save-tricks'><span class='cb-ref'>**</span></a>. Linux dudes know how to find them without any <a id='help-linux-file-list-with-hidden-files' title='try: ls -al ;o)'>help from me</a>.<br/> <div class='image-left'> <img title='Mac Finder view with invisible files' alt='Mac Finder view with invisible files' src='http://corz.org/serv/tricks/img/mac-view.png'/><br/> <small><strong>that same folder, as seen from Mac OS X</strong></small> </div><br/> <br/> In both images, the operating system has been instructed to <em>display</em> invisible files. ugly, but necessary sometimes. You will also need to instruct your ftp client to do the same.<br/> <br/> By the way; the windows screencap is more recent than the mac one, moved files are likely being handled by my clever <a id='link-404' title='catch those lost visitors!' href='http://corz.org/nah/no/page/here/mac'>404 script</a>.<br/> <br/> <div id='windows-invisible-save-tricks' class='tiny-space'> </div> <blockquote> <div class='blockquote'> <div class='reftext'>** even notepad can save files beginning with a dot, if you put double-quotes around the name when you save it; i.e.. ".htaccess". You can also use your ftp client to rename files beginning with a dot, even on your local filesystem; works great in <a id='link-FileZilla-ftp-client' title='A rather neat FTP client, or rather two ftp clients, it's all rather confusing, but version 2 is still better!' href='http://filezilla-project.org/'>FileZilla</a>.</div> </div> </blockquote><br/> <div class='small-space' id='section-what_is_htaccess'> </div> <h2>What <em>are</em> .htaccess files anyway?</h2> Simply put, they are invisible plain text files where one can store <strong>server directives</strong>. Server directives are anything you might put in an Apache config file (<tt>httpd.conf</tt>) or even a <tt>php.ini</tt><span class='cb-ref'>**</span>, but unlike those "master" directive files, these .htaccess directives apply only to the folder in which the .htaccess file resides, <em>and all the folders inside</em>. <br/> <br/>This ability to plant .htaccess files in any directory of our site allows us to set up a finely-grained tree of server directives, each subfolder inheriting properties from its parent, whilst at the same time adding to, or over-riding certain directives with its own .htaccess file. For instance, you could use .htacces to enable indexes all over your site, and then deny indexing in only certain subdirectories, <em>or</em> deny index listings site-wide, and <em>allow</em> indexing in certain subdirectories. One line in the .htaccess file in your root and your whole site is altered. From here on, I'll probably refer to the main .htaccess in the root of your website as "the master .htaccess file", or "main" .htaccess file.<br/> <br/> There's a small performance penalty for all this .htaccess file checking, but not noticeable, and you'll find most of the time <em>it's just on</em> and there's nothing you can do about it anyway, so let's make the most of it..<br/> <br/> <div class='small brown'>** Your main <tt>php.ini</tt>, that is, unless you are running under phpsuexec, in which case the directives would go inside <em>individual</em> <tt>php.ini</tt> files</div> <div class='small-space' id='section-is-it-enabled'> </div> <h2>Is .htaccess enabled?</h2> It's unusual, but possible that .htaccess is not enabled on your site. If you are hosting it yourself, it's easy enough to fix; open your <tt>httpd.conf</tt> in a text editor, and locate this <tt><Directory></tt> section..<br/> <blockquote> <div class='blockquote'> <div class='codetop'> <em>Your </em> <tt> DocumentRoot</tt> may be different, of course.. </div> <div class='codeblock'> # This should be changed to whatever you set DocumentRoot to.<br/> #<br/> <Directory "/var/www/htdocs"><br/> # </div> </div> </blockquote> <br/> ..locate the line that reads..<br/> <blockquote> <div class='blockquote'> <div class='codeblock'> AllowOverride None </div> </div> </blockquote> <br/> ..and change it to..<br/> <blockquote> <div class='blockquote'> <div class='codeblock'> AllowOverride All </div> </div> </blockquote> <br/>Restart Apache. Now .htaccess will work. You can also make this change inside a virtual host, which would normally be preferable.<br/> <br/>If your site is hosted with someone else, check your control panel (Plesk. CPanel, etc.) to see if you can enable it there, and if not, contact your hosting admins. Perhaps they don't allow this. In which case, switch to a better web host.<br/> <br/> <div class='small-space' id='What-Can-I-Do-with-htaccess'> </div> <h2>What can I do with .htaccess files?</h2> Almost any directive that you can put inside an <tt>httpd.conf</tt> file will also function perfectly inside an .htaccess file. Unsurprisingly, the most common use of .htaccess is to..<br/> <div class='small-space' id='section-control_and_deny_access'> </div> <h2>Control access..</h2> .htaccess is most often used to restrict or deny access to individual files and folders. A typical example would be an "includes" folder. Your site's pages can call these included scripts all they like, but you don't want users accessing these files directly, over the web. In that case you would drop an .htaccess file in the includes folder with content something like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> NO ENTRY! </div> <div class='codeblock'> # no one gets in here!<br/> deny from all<br/> </div> </div> </blockquote> <br/>which would deny ALL direct access to ANY files in that folder. You can be more specific with your conditions, for instance limiting access to a particular IP range, here's a handy top-level rule for a local test server..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> NO ENTRY outside of the LAN! </div> <div class='codeblock'> # no nasty crackers in here!<br/> order deny,allow<br/> deny from all<br/> allow from 192.168.0.0/24<br/> # this would do the same thing..<br/> #allow from 192.168.0<br/> </div> </div> </blockquote> <br/>Generally these sorts of requests would bounce off your firewall anyway, but on a live server (like my dev mirror sometimes is) they become useful for filtering out undesirable IP blocks, known risks, lots of things. By the way, in case you hadn't spotted; lines beginning with "#" are ignored by Apache; handy for comments.<br/> <br/> Sometimes, you will only want to ban one IP, perhaps some persistent robot that doesn't play by the rules..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> post user agent every fifth request only. hmmm. ban IP.. </div> <div class='codeblock'> # someone else giving the ruskies a bad name..<br/> order allow,deny<br/> deny from 83.222.23.219<br/> allow from all<br/> </div> </div> </blockquote> <br/>The usual rules for IP addresses apply, so you can use partial matches, ranges, and so on. Whatever, the user gets a 403 "access denied" error page in their client software (browser, usually), which certainly gets the message across. This is probably fine for most situations, but in <a title='redirecting with mod_rewrite (vodoo)' href='http://corz.org/serv/tricks/htaccess2.php#cooldenial'> part two</a> I'll demonstrate some cooler ways to deny access.<br/> <div class='small-space' id='section-custom_error_documents'> </div> <h2>Custom error documents..</h2> I guess I should briefly mention that .htaccess is where most folk configure their error documents. Usually with sommething like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> the usual method. the "err" folder (with the custom pages) is in the root </div> <div class='codeblock'> # custom error documents<br/> ErrorDocument 401 /err/401.php<br/> ErrorDocument 403 /err/403.php<br/> ErrorDocument 404 /err/404.php<br/> ErrorDocument 500 /err/500.php<br/> </div> </div> </blockquote> <br/>You can also specify external URLs, though this can be problematic, and is best avoided. One quick and simple method is to specify the text in the directive itself, you can even use HTML (though there is probably a limit to how much HTML you can squeeze onto one line). Remember, for Apache 1; begin with a <strong>"</strong>, but DO NOT end with one. For Apache 2, you can put a second quote at the end, as normal.<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> measure twice, quote once.. </div> <div class='codeblock'> # quick custom error "document"..<br/>ErrorDocument 404 "<html><head><title>NO!</title></head><body><h2><tt>There is nothing here.. go away quickly!</tt></h2></body></html> </div> </div> </blockquote> <br/> Using a custom error document is a Very Good Idea, and will give you a second chance at your almost-lost visitors. I recommend you <a id='link-404-be-clever' title='catch those lost visitors!' href='http://corz.org/engine?section=php&download=menu'>download mine</a>. But then, I would.<br/> <div class='small-space' id='section-password_protection'> </div> <h2>Password protected directories..</h2> The next most obvious use for our .htaccess files is to allow access to only specific users, or user groups, in other words; password protected folders. a simple authorisation mechanism might look something like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> a simple sample .htaccess file for password protection: </div> <div class='codeblock'> AuthType Basic<br/> AuthName "restricted area"<br/> AuthUserFile /usr/local/var/www/html/.htpasses<br/> require valid-user<br/> </div> </div> </blockquote> <br/> You can use this same mechanism to limit only <em>certain kinds</em> of requests, too..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> only valid users can POST in here, anyone can GET, PUT, etc: </div> <div class='codeblock'> AuthType Basic<br/> AuthName "restricted area"<br/> AuthUserFile /usr/local/var/www/html/.htpasses<br/> <Limit POST><br/> require valid-user<br/> </Limit><br/> </div> </div> </blockquote> <br/> You can find loads of <a onclick='window.open(this.href); return false;' title='apache docs - essential viewing (opens in a new window - apple-click (shift-click on peecees) for a new tab instead)' href='http://httpd.apache.org/docs/howto/auth.html'>online examples</a> of how to setup authorization using .htaccess, and so long as you have a <em>real</em> user (or create one, in this case, 'jimmy') with a <em>real</em> password (you will be prompted for this, twice) in a <em>real</em> password file (the <tt>-c</tt> switch will create it)..<br/> <br/> <tt>htpasswd -c /usr/local/var/www/html/.htpasses jimmy</tt><br/> <br/> ..the above will work just fine. <tt>htpasswd</tt> is a tool that comes free with Apache, specifically for making and updating password files, check it out. The windows version is the same; only the file path needs to be changed; to wherever you want to put the password file.<br/> <br/> <strong>Note:</strong> if the Apache <tt>bin/</tt> folder isn't in your PATH, you will need to <a id='help-command-cd' title='cd: change directory. a fairly universal computer command to move the working folder to somewhere else'><tt>cd</tt></a> into that directory before performing the command. Also note: You can use forward and back-slashes interchangeably with Apache/php on Windows, so this would work just fine..<br/> <br/> <tt>htpasswd -c c:/unix/usr/local/Apache2/conf/.htpasses jimmy</tt><br/> <br/> Relative paths are fine too; assuming you were inside the <tt>bin/</tt> directory of our fictional Apache install, the following would do exactly the same as the above..<br/> <br/> <tt>htpasswd -c ../conf/.htpasses jimmy</tt><br/> <br/> Naming the password file <tt>.htpasses</tt> is a habit from when I had to keep that file inside the web site itself, and as web servers are configured to ignore files beginning with <tt>.ht</tt>, they too, remain hidden. If you keep your password file <em>outside</em> the web root (a better idea), then you can call it whatever you like, but the <tt>.ht_something</tt> habit is a good one to keep, even inside the web tree, it is secure enough for our <em>basic</em> purpose..<br/> <br/> Once they are logged in, you can access the <tt>remote_user</tt> environmental variable, and do stuff with it..<br/> <blockquote> <div id='rewrite-preview' class='blockquote'> <div class='codetop'> the <tt>remote_user</tt> variable is now available.. </div> <div class='codeblock'> RewriteEngine on<br/> RewriteCond %{remote_user} !^$ [nc]<br/> RewriteRule ^(.*)$ /users/%{remote_user}/$1<br/> </div> </div> </blockquote> <br/> Which is a handy directive, utilizing <tt>mod_rewrite</tt>; a subject I delve into <em>far</em> more deeply, in <a title='.htaccess mod_rewrite tricks and tips, URL shortening, and more..' href='http://corz.org/serv/tricks/htaccess2.php'>part two</a>.<br/> <div class='small-space' id='dont-htaccess-password-userauth'> </div> <h2>Get better protection..</h2> The authentication examples above assume that your web server supports "Basic" http authorisation, as far as I know they all do (it's in the Apache core). Trouble is, some browsers aren't sending password this way any more, personally I'm looking to <a onclick='window.open(this.href); return false;' id='link-php-security--auth-javascript-login' title='php and javascript advanced md5 authentication system, and more..' href='http://corz.org/engine?source=menu&section=php%2Fsecurity'>php</a> to cover my authorization needs. Basic auth works okay though, even if it isn't actually very secure - your password travels in <strong>plain text</strong> over the wire, not clever.<br/> <br/> If you have php, and are looking for a more secure login facility, check out <a id='link-pajamas' title='php and javascript advanced md5 authentication system' href='http://corz.org/serv/security/pajamas.php'>pajamas</a>. It's free. If you are looking for a password-protected download facility (and much more, besides), check out my <a id='link-pajamas-security' title='and the admin login uses pajamas!' href='http://corz.org/serv/tools/distromachine/'>distro machine</a>, also free. <div class='small-space' id='section-500_error'> </div> <h2>500 error..</h2> If you add something that the server doesn't understand or support, you will get a 500 error page, aka.. "the server did a boo-boo". Even directives that work perfectly on your test server at home may fail dramatically at your real site. In fact this is a great way to find out if .htaccess files are enabled on your site; create one, put some gibberish in it, and load a page in that folder, wait for the 500 error. if there isn't one, probably they are <em>not</em> enabled.<br/> <br/> If they are, we need a way to safely do live-testing without bringing the whole site to a 500 standstill.<br/> <br/> Fortunately, in much the same way as we used the <tt><Limit></tt> tag above, we can create <em>conditional</em> directives, things which will only come into effect if <em>certain conditions</em> are true. The most useful of these is the "ifModule" condition, which goes something like this.. <br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> only if PHP is loaded, will this directive have any effect (switch the 4 for a 5 if using php5) </div> <div class='codeblock'> <ifModule mod_php4.c><br/> php_value default_charset utf-8<br/> </ifModule><br/> </div> </div> </blockquote> <br/>..which placed in your master .htaccess file, that would set the default character encoding of your entire site to utf-8 (a good idea!), at least, anything output by PHP. If the PHP4<sup><tt>**</tt></sup> module isn't running on the server, the above .htaccess directive will do exactly nothing; Apache just ignores it. As well as proofing us against knocking the server into 500 mode, this also makes our .htaccess directives that wee bit more portable. Of course, if your syntax is messed-up, no amount of if-module-ing is going to prevent a error of some kind, all the more reason to practice this stuff on a local test server.<br/> <br/> <blockquote> <div class='blockquote'> <div class='reftext'><tt>**</tt> note: if you are using php5, you would obviously instead use <tt><ifModule mod_php5.c></tt>.</div> </div> </blockquote><br/> <div class='small-space' id='section-custom_indexing'> </div> <h2>Groovy things to do with .htaccess..</h2> So far we've only scratched the surface. Aside from authorisation, the humble .htaccess file can be put to all kinds of uses. If you've ever had a look in my <a title='free stuff to download, scripts, files, mac tools, that sort of thing' href='http://corz.org/public/'>public archives</a> you will have noticed that that the directories are fully browsable, just like in the old days before adult web hosts realized how to turn that feature off! A line like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> bring back the directories! </div> <div class='codeblock'> Options +Indexes +MultiViews +FollowSymlinks </div> </div> </blockquote> <br/> ..will almost certainly turn it back on again. And if you have <tt>mod_autoindex.c</tt> installed on your server (probably, yes), you can get nice fancy indexing, too..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> show me those files! </div> <div class='codeblock'> <IfModule mod_autoindex.c><br/> IndexOptions FancyIndexing <br/> </ifModule> </div> </div> </blockquote> <br/>..which, as well as being neater, allows users to click the titles and, for instance, order the listing by date, or file size, or whatever. It's all for free too, built-in to the server, we're just switching it on. You can control certain parameters too..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> let's go all the way! </div> <div class='codeblock'> <IfModule mod_autoindex.c><br/> IndexOptions FancyIndexing IconHeight=16 IconWidth=16<br/> </ifModule> </div> </div> </blockquote> <br/> Other parameters you could add include..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codeblock'> NameWidth=30<br/> DescriptionWidth=30<br/> IconsAreLinks SuppressHTMLPreamble (handy!) </div> </div> </blockquote> <br/> I'm not mentioning the "XHTML" parameter in Apache2, because it still isn't! Anyways, I've chucked one of my old <a title='if you use it, do leave the corz.org notice in, ta!' href='http://corz.org/serv/resources/file_view.htaccess.txt'>fancy indexing .htaccess file</a> onsite for you to have some fun with. Just add readme.html and away you go! note: these days I use a single header files for <em>all</em> the indexes..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codeblock'> HeaderName /inc/header.html </div> </div> </blockquote> <br/> .. and only drop in local "readme" files. Check out the example, and my <a id='link-public-archives' title='Fancy Indexing is only used in certain parts' href='http://corz.org/public/'>public archives </a>for more details.<br/> <div class='small-space' id='custom-index-files'> </div> <h2>custom directory index files</h2> While I'm here, it's worth mentioning that <tt>.htaccess</tt> is where you can specify which files you want to use as your indexes, that is, if a user requests <tt>/foo/</tt>, Apache will serve up <tt>/foo/index.html</tt>, or whatever file you specify. <br/> <br/>You can also specify multiple files, and Apache will look for each in order, and present the first one it finds. It's generally setup something like.. <blockquote> <div class='blockquote'> <div class='codeblock'> DirectoryIndex index.html index.php index.htm </div> </div> </blockquote> <br/> <br/>It really is worth scouting around the Apache documentation, often you will find controls for things you imagined were uncontrollable, thereby creating new possibilities, better options for your website. My experience of the magic "LAMP" (Linux-Apache-MySQL-PHP) has been.. "If you can imagine that it can be done, it can be done". Swap "Linux" for any decent operating system, the "AMP" part runs on most of them.<br/> <br/> Okay, so now we have nice fancy directories, and some of them password protected, if you don't watch out, you're site will get <em>popular</em>, and that means <em>bandwidth</em>..<br/> <div class='small-space' id='section-save_hard_cash'> </div> <h2>Save bandwidth with .htaccess!</h2> If you pay for your bandwidth, this wee line could save you hard <strong>cash</strong>..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> save me hard cash! and help the internet! </div> <div class='codeblock'> <ifModule mod_php4.c><br/> php_value zlib.output_compression 16386<br/> </ifModule><br/> </div> </div> </blockquote> <br/>All it does is enables PHP's built-in transparent zlib compression. This will half your bandwidth usage in one stroke, more than that, in fact. Of course it only works with data being output by the PHP module, but if you design your pages with this in mind, you can use php echo statements, or better yet, php "includes" for your plain html output and just compress <em>everything!</em> Remember, if you run phpsuexec, you'll need to put php directives in a local <tt>php.ini</tt> file, not .htaccess. See <a onclick='window.open(this.href); return false;' id='link-devblog-phpsuexec' title='phpsuexec, it's alright, actually.' href='http://corz.org/devblog/2006-Q1/phpsuexec'>here</a> for more details.<br/> <div class='small-space' id='section-hide_and_deny_files'> </div> <h2>Hide and deny files..</h2> Do you remember I mentioned that any file beginning with .ht is invisible? .."almost every web server in the world is configured to ignore them, by default" and that is, of course, because .ht_anything files generally have server directives and passwords and stuff in them, <em>most</em> servers will have something like this in their main configuration..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> Standard setting.. </div> <div class='codeblock'> <Files ~ "^\.ht"><br/> Order allow,deny<br/> Deny from all<br/> Satisfy All<br/> </Files><br/> </div> </div> </blockquote> <br/>which instructs the server to deny access to any file beginning with .ht, effectively protecting our .htaccess and other files. The "." at the start prevents them being displayed in an index, and the .ht prevents them being accessed. This version..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> ignore what you want </div> <div class='codeblock'> <Files ~ "^.*\.([Ll][Oo][Gg])"><br/> Order allow,deny<br/> Deny from all<br/> Satisfy All<br/> </Files><br/> </div> </div> </blockquote> <br/>tells the server to deny access to *.log files. You can insert multiple file types into each rule, separating them with a pipe "|", and you can insert multiple blocks into your .htaccess file, too. I find it convenient to put all the files starting with a dot into one, and the files with denied extensions into another, something like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> the whole lot </div> <div class='codeblock'> # deny all .htaccess, .DS_Store $hî†é and ._* (resource fork) files<br/> <Files ~ "^\.([Hh][Tt]|[Dd][Ss]_[Ss]|[_])"><br/> Order allow,deny<br/> Deny from all<br/> Satisfy All<br/> </Files><br/> <br/> # deny access to all .log and .comment files<br/> <Files ~ "^.*\.([Ll][Oo][Gg]|[cC][oO][mM][mM][eE][nN][tT])"><br/> Order allow,deny<br/> Deny from all<br/> Satisfy All<br/> </Files><br/> </div> </div> </blockquote> <br/> would cover all ._* resource fork files, .DS_Store files (which the Mac <a title='a bit like 'explorer' on windows, but the finder is the original>.'>Finder</a> creates <em>all over the place</em>) *.log files, *.comment files and of course, our .ht* files. You can add whatever file types you need to protect from direct access. I think it's clear now why the file is called ".htaccess". <br/> <div class='small-space' id='section-filesmatch'> </div> <h2><FilesMatch></h2> These days, using <tt><FilesMatch></tt> is preferred over <tt><Files></tt>, mainly because you can use regular expression in the conditions (very handy), produce clean, more readable code. Here's an example. which I use for my php-generated style sheets..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> parse file.css and file.style with the php machine.. </div> <div class='codeblock'> # handler for phpsuexec..<br/> <FilesMatch "\.(css|style)$"><br/> SetHandler application/x-httpd-php<br/> </FilesMatch><br/> </div> </div> </blockquote> <br/> Any files with a <tt>*.css</tt> or <tt>*.style</tt> extension will now be handled by php, rather than simply served up by Apache. And because you can use regexp, you could do stuff like <tt><FilesMatch "\.s?html$"></tt>, which is handy. Any <tt><Files></tt> statements you come across can be advantageously replaced by <tt><FilesMatch></tt> statements. Good to know.<br/> <div class='small-space' id='section-php_directives'> </div> <h2>More stuff..</h2> At the end of my .htaccess files, there always seems to be a section of "stuff"; miscellaneous commands, mainly php flags and switches; so it seems logical to finish up the page with a wee selection of those..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> php flags, switches and other stuff.. </div> <div class='codeblock'> # let's enable php (non-cgi, aka. 'module') for <em>EVERYTHING</em>..'<br/> AddType application/x-httpd-php5 .htm .html .php .blog .comment .inc<br/> <br/> # better yet..<br/> AddHandler php5-script .php<br/> <br/> # legacy php4 version..'<br/> AddType application/x-httpd-php .htm .html .php .blog .comment .inc<br/> <br/> # don't even think about setting this to 'on'<br/> <a id='help-register_globals' title='enable this to probably break your site's security'>php_value register_globals off</a><br/> <br/> # no session id's in the URL PULEEZE!<br/> php_value session.use_trans_sid 0<br/> # should be the same as..<br/> php_flag session.use_trans_sid off<br/> # using both should also work fine!<br/> <br/> # php error logs..<br/> php_flag display_errors off<br/> php_flag log_errors on<br/> <a id='help-track_errors' title='if enabled, the last error message is available in the variable $php_errormsg'>php_value track_errors on</a><br/> php_value error_log /home/cor/errors/phperr.log<br/> <br/> # if you like to collect interesting php system shell access and web hack scripts<br/> # get yourself a SECURE upload facility, and just let the script-kiddies come …<br/> # in no time you will have a huge selection of fascinating code. If you want folk to<br/> # also upload zips and stuff, you might want to increase the upload capacities..<br/> php_value upload_max_filesize 12M<br/> php_value post_max_size 12M<br/> <br/> # php 5 only, afaik. handy when your server isn't where YOU are.<br/> php_value date.timezone Europe/Aberdeen<br/> # actually, Europe/Aberdeen isn't a valid php timezone, so that won't work.<br/> # I recommend you check the php manual for this function, because many crazy places ARE! </div> </div> </blockquote> <br/> Note: For most of the flags I've tested, you can use <tt>on</tt>/<tt>off</tt> and <tt>true</tt>/<tt>false</tt> interchangeably, as well as <tt>0</tt>/<tt>1</tt>, also <tt>php_value</tt> and <tt>php_flag</tt> can be switched around while things continue to work as expected! I guess, logically, booleans should always be <tt>php_flag</tt>, and values, <tt>php_value</tt>; but suffice to say, if some php erm, <em>directive</em> isn't working, these would all be good things to fiddle with!<br/> <br/>Of course, the php manual explains all. The bottom line is; both will work fine, but if you use the wrong type in .htaccess, say, set a <tt>php_flag</tt> using <tt>php_value</tt>, a php <tt>ini_get()</tt> command, for instance, would return <tt>true</tt>, even though you had set the value to <tt>off</tt>, because it reads <tt>off</tt> value as a <em>string</em>, which of course evaluates to not-zero, i.e. 1, or "true". If you don't rely on <tt>get_ini()</tt>, or similar, it's not a problem, though clearly it's better to get it right from the start. By the way; <a id='link-trick-examples' title='Okay, two!'>one</a> of the values above is incorrectly set. Did you spot it?<br/> <br/>Most php settings, you can override inside your actual scripts, but I do find it handy to be able to set defaults for a folder, or an entire site, using .htaccess.<br/> <div class='small-space' id='seeya--in-part-two'> </div> <h2>over to you..</h2> That should get you started with .htaccess, quite easy when you know how. If you really want to bend your brain out of shape, follow the link below for part two of the series, where I delve into the arcane mysteries of URL rewriting.<br/> <br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=2ccac5d8-f1ec-82ab-907e-ffe085055143' alt='' class='zemanta-pixie-img'/></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-40026995212029374912009-08-12T00:15:00.001+07:002009-08-12T00:15:26.792+07:00<div xmlns='http://www.w3.org/1999/xhtml'><h1>more .htaccess tips and tricks..</h1> <div class='ht-title'><ifModule><br/><span class='clever'>more clever stuff here</span><br/></ifModule></div> <div class='small-space'> </div> <h2>redirecting and rewriting</h2> <blockquote> <div id='quote-intro' class='blockquote'> <em>"The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail."</em><br/> <br/> <div class='right'>- Brian Behlendorf, Apache Group</div> </div> </blockquote> <div class='small-space' id='section-intro'> </div> <br/> <div id='intro'> One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs. This enables us to do some mighty manipulations on our links; useful stuff like transforming very long URL's into short, cute URLs, transforming dynamic <span class='urltxt'>?generated=page&URL's</span> into /friendly/flat/links, redirect missing pages, preventing hot-linking, performing automatic language translation, and much, much more.<br/> <br/> Make no mistake, <tt>mod_rewrite</tt> is <em>complex</em>. This isn't the subject for a quick bite-size tech-snack, probably not even a week-end crash-course, I've seen guys pull off some real cute stuff with <tt>mod_rewrite</tt>, but with kudos-hat tipped firmly towards that bastard operator from hell, Ralf S. Engelschall, author of the magic module itself, I have to admit that a great deal of it still seems so much voodoo to me.<br/> <br/> The way that rules can work one minute and then seem not to the next, how browser and other in-between network caches interact with rules and testing rules is often baffling, maddening. When I feel the need to bend my mind completely out of shape, I mess around with <tt>mod_rewrite</tt>!<br/> <br/>After all this, it does work, and while I'm not planning on taking that week-end crash-course any time soon, I have picked up a few wee tricks myself, messing around with webservers and web sites, this place.. <br/> <br/>The plan here is to just drop some neat stuff, examples, things that have proven useful, and work on a variety of server setups; there are apache's all over my LAN, I keep coming across old .htaccess files stuffed with past rewriting experiments that either worked; and I add them to my list, or failed dismally; and I'm surprised that more often these days, I can <em>see exactly why!</em><br/> <br/> Very little here is my own <a id='this-article-MIRRORED-hahahah-worldwide' title='well, okay, a couple of things I did 'invent' - the auto-translation came to me in a dream, and then there's - a limit to anchor titles! ;o)'>invention</a>. Even the bits I figured out myself were already well documented, I just hadn't understood the documents, or couldn't find them. Sometimes, just looking at the same thing from a different angle can make all the difference, so perhaps this humble stab at URL Rewriting might be of some use. I'm writing it for me, of course. but I do get some credit for this..<br/> <br/> <blockquote> <div id='intro-time-to-get-dynamic' class='blockquote'> <code> <span class='code-comment'># time to get dynamic, see..</span><br/> RewriteRule (.*)\.htm $1.php<br/> </code> </div> </blockquote> </div> <div class='tiny-space' id='section-beginning'> </div> <br/> <h3>beginning rewriting..</h3> <div id='beginning'> Whenever you use <tt>mod_rewrite</tt> (the part of apache that does all this magic), you need to do..<br/> <br/> <blockquote> <div id='rewrite-rule-follow-symlinks' class='blockquote'> <div class='codetop'> you only need to do this once per .htaccess file: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> </div> </div> </blockquote> <br/> ..before any ReWrite rules. <strong>note:</strong> <tt>+FollowSymLinks</tt> <strong>must</strong> be enabled for <em>any</em> rules to work, this is a security requirement of the rewrite engine. Normally it's enabled in the root and you shouldn't have to add it, but it doesn't hurt to do so, and I'll insert it into all the examples on this page, just in case*. <br/> <br/> The next line simply switches on the rewrite engine for that folder. if this <a title='any instruction for a server, either in an httpd.conf, a php.ini, or an .htaccess file is called a 'directive''>directive</a> is in you main .htaccess file, then the ReWrite engine is theoretically enabled for your entire site, but it's wise to always add that line before you write any redirections, <em>anywhere</em>.<br/> <br/> <small><strong>* </strong>Although highly unlikely, your host may have <tt>+FollowSymLinks</tt> enabled at the root level, yet <em>disallow</em> its addition in .htaccess; in which case, adding <tt>+FollowSymLinks</tt> will break your setup (probably a 500 error), so just remove it, and your rules should work fine.</small><br/> <br/> <small><strong>Important:</strong> While some of the directives on this page may appear split onto two lines, in your .htaccess file, they <em>must</em> exist completely on one line. If you drag-select and copy the directives on this page, they should paste just fine into any text editor.</small><br/> </div> <div class='small-space' id='section-simple_rewriting'> </div><br/> <h3>simple rewriting</h3> <div id='simple'> Simply put, Apache scans all incoming URL requests, checks for matches in our .htaccess file and rewrites those matching URLs to whatever we specify. something like this..<br/> <br/> <blockquote> <div id='rewrite-rule-htm-to-php' class='blockquote'> <div class='codetop'> all requests to whatever.htm will be sent to whatever.php: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.*)\.htm$ $1.php [NC]<br/> </div> </div> </blockquote> <br/>Handy for anyone updating a site from static htm (you could use .html, or .htm(.*), .htm?, etc) to dynamic php pages; requests to the old pages are automatically rewritten to our new urls. no one notices a thing, visitors and search engines can access your content either way. leave the rule in; as an added bonus, this enables us to easily split php code and its included html structures into two separate files, a nice idea; makes editing and updating a breeze. The [NC] part at the end means "No Case", or "case-insensitive"; more on the switches, later.<br/> <br/>Folks can link to whatever.htm or whatever.php, but they always get whatever.php in their browser, and this works even if whatever.htm doesn't exist! But I'm straying..<br/> <br/>As it stands, it's a bit tricky; folks will still have whatever.htm in their browser address bar, and will still keep bookmarking your old .htm URL's. Search engines, too, will keep on indexing your links as .htm, some have even argued that serving up the same content from two different places could have you <em>penalized</em> by the search engines. This may or not bother you, but if it does, <tt>mod_rewrite</tt> can do some more magic..<br/> <br/> <blockquote> <div id='rewrite-rule-htm-to-php-permanent' class='blockquote'> <div class='codetop'> this will do a "real" external redirection: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.+)\.htm$ http://corz.org/$1.php [R,NC]<br/> </div> </div> </blockquote> <br/> This time we instruct <tt>mod_rewrite</tt> to do a proper external rewrite, aka, "redirection". Now, instead of just background rewriting on-the-fly, the user's browser is physically redirected to a new URI, and <tt>whatever.php </tt>appears in their browser's address bar - search engines and other spidering entities will automatically update their links to the .php versions; everyone wins. You can take your time with the updating, too.<br/> <br/> Note: if you use <tt>[R]</tt> alone, it defaults to sending an HTTP "MOVED TEMPORARILY" redirection, aka, "302". But you can send other codes, like so..<br/> <br/> <blockquote> <div id='rewrite-rule-htm-to-php-permanent-301' class='blockquote'> <div class='codetop'> this performs the exact same as the previous example RewriteRule. </div> <div class='codeblock'> RewriteRule ^(.+)\.htm$ http://corz.org/$1.php [R=302,NC]<br/> </div> </div> </blockquote> <br/> Okay, I sent the exact same code, but I didn't <em>have</em> to. For details of the many <tt>30*</tt> response codes you can send, see <a id='link-http-response-codes' title='Stick with the 300 range!' href='http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html'>here</a>. Most people seem to want to send <tt>301</tt>, aka, "MOVED PERMENENTLY". <br/> <br/> Note: if you add an "L" flag to the mix; meaning "Last Rule", e.g. <tt>[R=302,NC,L]</tt>; Apache will stop processing rules <em>for this request</em> at that point, which may or may not be what you want. Either way, it's useful to know. </div> <div class='small-space' id='section-not_so_simple'> </div><br/> <h3>not-so-simple rewriting ... flat links and more</h3> <div id='not-so-simple'> You may have noticed, the above examples use <em><a title='mod_rewrite uses POSIX standard regular expressions'>regular expression</a></em> to match variables. What that simply means is.. match the part inside (.+) and use it to construct "$1" in the new URL. In other words, (.+) = $1 you could have multiple (.+) parts and for each, <tt>mod_rewrite</tt> automatically creates a matching $1, $2, $3, etc, in your target (aka. 'substitution') URL. This facility enables us to do all sorts of tricks, and the most common of those, is the creation of "flat links"..<br/> <br/> Even a cute short link like <span class='urltxt'>http://mysite/grab?file=my.zip</span> is too ugly for some people, and nothing less than a true old-school solid <span class='urltxt'>domain/path/flat/link</span> will do. Fortunately, <tt>mod_rewrite</tt> makes it easy to convert URLs with query strings and multiple variables into exactly this, something like..<br/> <br/> <blockquote> <div id='rewrite-rule-with-regex' class='blockquote'> <div class='codetop'> a more complex rewrite rule: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?section=$1&file=$2 [NC]<br/> </div> </div> </blockquote> <br/> would allow you to present this link as..<br/> <br/> <span class='urltxt'> http://mysite/files/games/hoopy.zip</span><br/> <br/> and in the background have that transparently translated, server-side, to..<br/> <br/> <span class='urltxt'> http://mysite/download.php?section=games&file=hoopy</span><br/> <br/> which some script could process. You see, many search engines simply don't follow our <span class='urltxt'>?generated=links</span>, so if you create generating pages, this is useful. However, it's only the dumb search engines that can't handle these kinds of links; we have to ask ourselves.. do we really want to be listed by the dumb search engines? <a onclick='window.open(this.href); return false;' title='the world's number one search engine' href='http://www.google.com'>Google</a> will handle a good few parameters in your URL without any problems, and the (hungry hungry) <a title='many now have .htaccess deny rules in place for this voracious page-guzzler!' href='http://search.msn.com/msnbot.htm'>msn-bot</a> stops at nothing to <em>get that page</em>, sometimes again and again and again…<br/> <br/>I personally feel it's the search engines that should strive to keep up with modern web technologies, in other words; we shouldn't have to dumb-down for them. But that's just my opinion. Many <em>users</em> will prefer <span class='urltxt'>/files/games/hoopy.zip</span> to <span class='urltxt'>/download.php?section=games&file=hoopy</span> but I don't mind either way. As someone pointed out to me recently, presenting links as <span class='urltxt'>standard/flat/paths</span> means you're less likely to get folks doing typos in typed URL's, so something like..<br/> <br/> <blockquote> <div id='rewrite-rule-more-comlex-regex' class='blockquote'> <div class='codetop'> an even more complex rewrite rule: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^blog/([0-9]+)-([a-z]+) http://corz.org/blog/index.php?archive=$1-$2 [NC]<br/> </div> </div> </blockquote> <br/> would be a neat trick, enabling anyone to access my blog archives by doing..<br/> <br/> <a title='any excuse for an inward link!' href='http://corz.org/blog/2003-nov'><span class='urltxt'>http://corz.org/blog/2003-nov</span></a><br/> <br/> in their browser, and have it automagically transformed server-side into..<br/> <br/> <a title='ditto!' href='http://corz.org/blog/index.php?archive=2003-nov'><span class='urltxt'>http://corz.org/blog/index.php?archive=2003-nov</span></a><br/> <br/>which <a title='drop-in-and-blog blogging software from corz.org' href='http://corz.org/blog/'>corzblog</a> would understand. It's easy to see that with a little imagination, and a basic understanding of <a onclick='window.open(this.href); return false;' title='understanding regex will empower you in ways you would not imagine' href='http://www.google.com/search?q=posix+regular+expression+syntax'> posix regular expression</a>, you can perform some highly cool URL manipulations.<br/> <br/> Here's the very basics of regexp (expanded from the apache <tt>mod_rewrite</tt> documentation).. <div class='tiny-space' id='section-regexp_basics'> </div><br/> <blockquote id='regexp-basics-special-characters'> <div id='rewrite-rule-regexp-special-characters' class='blockquote'> <pre><strong>Escaping:</strong><br /><br /><strong>\</strong>char escape that particular char<br /><br /> For instance to specify special characters.. <strong>[].()\</strong> etc.<br /><br /><strong>Text:</strong><br /><br /><strong>.</strong> Any single character (on its own = the entire URI)<br /><strong>[</strong>chars<strong>]</strong> Character class: One of following chars<br /><strong>[^</strong>chars<strong>]</strong> Character class: None of following chars<br />text1<strong>|</strong>text2 Alternative: text1 or text2 (i.e. "or")<br /><br /> <strong>e.g.</strong> <strong>[^/]</strong> matches any character <em>except</em> <strong>/</strong><br /> <strong>(foo|bar)\.html</strong> matches <strong>foo.html</strong> <em>and</em> <strong>bar.html</strong><br /><br /><strong>Quantifiers:</strong><br /><br /><strong>?</strong> 0 or 1 of the preceding text<br /><strong>*</strong> 0 or N of the preceding text (hungry)<br /><strong>+</strong> 1 or N of the preceding text<br /><br /> <strong>e.g.</strong> <strong>(.+)\.html?</strong> matches <strong>foo.htm</strong> <em>and</em> <strong>foo.html</strong><br /> <strong>(foo)?bar\.html</strong> matches <strong>bar.html</strong> <em>and</em> <strong>foobar.html</strong><br /><br /><strong>Grouping:</strong><br /><br /><strong>(</strong>text<strong>)</strong> Grouping of text<br /><br /> Either to set the borders of an alternative or<br /> for making backreferences where the <strong>n</strong>th group can <br /> be used on the target of a RewriteRule with <strong>$n</strong><br /><br /> <strong>e.g. </strong> ^<strong>(.*)</strong>\.html foo.php?bar=<strong>$1</strong><br /><br /><strong>Anchors:</strong><br /><br /><strong>^</strong> Start of line anchor<br /><strong>$</strong> End of line anchor<br /><br /> An anchor explicitly states that the character <em>right next to it</em> MUST <br /> be either the very first character ("^"), or the very last character ("$")<br /> of the URI string to match against the pattern, e.g.. <br /> <br /> <strong>^foo(.*)</strong> matches <strong>foo</strong> and <strong>foobar</strong> but <em>not</em> <strong>eggfoo</strong><br /> <strong>(.*)l$</strong> matches <strong>fool</strong> and <strong>cool</strong>, but <em>not</em> <strong>foo</strong><br /></pre> </div> </blockquote> </div> <div class='small-space' id='section-short_URLs'> </div><br/> <h3>shortening URLs</h3> <div id='short-urls'> One common use of <tt>mod_rewrite</tt> is to shorten URL's. Shorter URL's are easier to remember and, of course, easier to type. An example..<br/> <br/> <blockquote> <div id='rewrite-rule-short-urls' class='blockquote'> <div class='codetop'> beware the regular expression: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteRule ^grab /public/files/download/download.php<br/> </div> </div> </blockquote> <br/> this rule would transform this user's URL..<br/> <br/> <span class='urltxt'> http://mysite/grab?file=my.zip</span><br/> <br/> server-side, into..<br/> <br/> <span class='urltxt'> http://mysite/public/files/download/download.php?file=my.zip</span><br/> <br/>which is a wee trick I use for my distro machine, among other things. everyone likes short URL's, and so will you; using this technique, you can move <span class='urltxt'>/public/files/download/</span> to <em>anywhere</em> else in your site, and all the old links still work fine; simply alter your .htaccess file to reflect the new location. edit one line, done - nice - means even when stuff is way deep in your site you can have cool links like this.. <script type='text/javascript'> // <!-- document.write("<a href=\"javascript:OpenWindow('/trueview/php/sample.php',432,460,330,150)\" title=\"just a simple link (opens in a windoid)\">/trueview/sample.php<\/a>") //--> // </script><a title='just a simple link (opens in a windoid)' href='javascript:OpenWindow('/trueview/php/sample.php',432,460,330,150)'>/trueview/sample.php</a> <noscript> <div> <a href='/trueview/php/sample.php'> /trueview/php/sample.php</a> </div> </noscript> and <a onclick='window.open(this.href); return false;' id='bbtagslink' title='the corzblog bbcode parser bbcode guide, way deep in the site' href='http://corz.org/bbtags'>this</a>; links which are not only short, but <em>flat</em>..<br/> </div> <div class='small-space' id='section-capturing_variables'> </div><br/> <h3>capturing variables</h3> <div id='capturing-variables'> Slapping <tt>(.*)</tt> onto the end of the request part of a <tt>ReWriteRule</tt> is just fine when using a simple <tt>$_GET</tt> variable, but sometimes you want to do trickier things, like capturing <em>particular</em> variables and converting them into <em>other</em> variables in the target URL. Or something else.. <br/> <br/> When capturing variables, the first thing you need to know about, is the <tt>[QSA]</tt> flag, which simply tags all the original variables back onto the end of the target url. This may be all you need, and will happen automatically for simple rewites. The second thing, is <tt>%{QUERY_STRING}</tt>, an Apache server string we can capture variables from, using simple <tt>RewriteCond</tt> (aka. <em>conditional</em> ) statements.<br/> <br/> <tt>RewriteCond</tt> is very like doing <tt><em>if...then...do</em></tt> in many programming languages. <em>If</em> a certain condition is true, <em>then</em> do the rewrite that follows..<br/> <br/> In the following example, the <tt>RewriteCond</tt> statement checks that the query string has the <tt>foo</tt> variable set, and captures its value while it's there. In other words, only requests for <tt>/grab</tt> that have the variable <tt>foo</tt> set, will be rewritten, and while we're at it, we'll also switch <tt>foo</tt>, for <tt>bar</tt>, just because we can..<br/> <br/> <blockquote> <div id='simple-capture-variables' class='blockquote'> <div class='codetop'> capturing a $_GET variable: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteCond %{QUERY_STRING} foo=(.*)<br/> RewriteRule ^grab(.*) /page.php?bar=%1<br/> </div> </div> </blockquote> <br/> would translate a link/user's request for..<br/> <br/> <tt>http://domain.com/grab?foo=bar</tt><br/> <br/> server-side, into..<br/> <br/> <tt>http://domain.com/page.php?bar=bar</tt><br/> <br/> Which is to say, the user's browser would be fed <tt>page.php</tt> (without an <tt>[R]</tt> flag in the <tt>RewriteRule</tt>, their address bar would still read <tt>/grab?foo=bar</tt>). The variable <tt>bar</tt> would be available to your script, with its value set to <tt>bar</tt>. This variable has been magically created, by simply using a regular <tt><strong>?</strong></tt> in the target of the <tt>RewriteRule</tt>, and tagging on the first captured backreference, <strong>%1</strong>.. <tt>?bar=%1</tt><br/> <br/> <strong>Note</strong> how we use the <code><strong>%</strong></code> character, to specify variables captured in <tt>RewriteCond</tt> statements, aka "Backreferences". This is exactly like using <strong>$1</strong> to specify numbered backreferences captured in <tt>RewriteRule</tt> patterns, except for strings captured inside a <tt>RewriteCond</tt> statement, we use <code><strong>%</strong></code> instead of <strong>$</strong>. Simple.<br/> <br/> You can use the <tt>[QSA]</tt> flag in <em>addition</em> to these query string manipulations, merge them. In the next example, the value of <tt>foo</tt> becomes the <em>directory</em> in the target URL, and the variable <tt>file</tt> is magically created. The original query string is then tagged back onto the end of the whole thing..<br/> <blockquote> <div id='more-complex-variable-capture' class='blockquote'> <div class='codetop'> QSA Overkill! </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteCond %{QUERY_STRING} foo=(.+)<br/> RewriteRule ^grab/(.*) /%1/index.php?file=$1 [QSA]<br/> </div> </div> </blockquote><br/> So a request for..<br/> <br/> <tt>http://domain.com/grab/foobar.zip?level=5&foo=bar</tt><br/> <br/> is translated, server-side, into..<br/> <br/> <tt>http://domain.com/bar/index.php?file=foobar.zip&level=5&foo=bar</tt><br/> <br/> Depending on your needs, you could even use flat links <em>and</em> dynamic variables together, something like this could be useful..<br/> <br/> <blockquote> <div id='variable-capture-mix-flat-and-dynamic-links' class='blockquote'> <div class='codetop'> mixing flat and dynamic links in a single ruleset.. </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteCond %{QUERY_STRING} version=(.+)<br/> RewriteRule ^grab/([^/]+)/(.*) /%1/index.php?section=$1&file=$2 [QSA]<br/> </div> </div> </blockquote><br/> By the way, you can easily do the <em>opposite</em>, strip a query string from a URL, by simply putting a <tt><strong>?</strong></tt> right at the end of the taget part. This example does exactly that, whilst leaving the actual URI intact..<br/> <br/> <blockquote> <div id='strip-variables' class='blockquote'> <div class='codetop'> just a demo! </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteCond %{QUERY_STRING} . <br/> RewriteRule foo.php(.*) /foo.php<strong>?</strong> [L] <br/> </div> </div> </blockquote> The <tt>RewriteCond</tt> statement only allows requests that have <em>something</em> in their query string, to be processed by the <tt>RewriteRule</tt>, or else we'd end up in that hellish place, dread to all mod_rewriters.. the endless loop. <tt>RewriteCond</tt> is often used like this; as a safety-net. </div> <div class='small-space' id='section-cooler_access_denied'> </div><br/> <h3>cooler access denied</h3> <div id='cooler-access-denied'> In <a title='... .htaccess tricks: authentication, indexing, and more' href='http://corz.org/serv/tricks/htaccess.php#denied'>part one</a> I demonstrated a drop-dead simple mechanism for denying access to particular files and folders. The trouble with this is the way our user gets a 403 "Access Denied" error, which is a bit like having a door slammed in your face. Fortunately, <tt>mod_rewrite</tt> comes to the rescue again and enables us to do less painful things. One method I often employ is to redirect the user to the parent folder..<br/> <br/> <blockquote> <div id='rewrite-rule-cool-access-denied' class='blockquote'> <div class='codetop'> they go "huh?.. ahhh!" </div> <div class='codeblock'> <span class='code-comment'># send them up!</span><br/> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.*)$ ../ [NC]<br/> </div> </div> </blockquote> <br/>It works great, though it can be a wee bit tricky with the URLs, and you may prefer to use a harder location, which avoids potential issues in indexed directories, where folks can get in a loop.. <br/> <br/> <blockquote> <div id='rewrite-rule-cooler-access-denied' class='blockquote'> <div class='codetop'> they go damn! Oh! </div> <div class='codeblock'> <span class='code-comment'># send them exactly there!</span><br/> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.*)$ /comms/hardware/router/ [NC]<br/> </div> </div> </blockquote> <br/> Sometimes you'll only want to deny access to <em>most</em> of the files in the directory, but allow access to maybe one or two files, or file types, easy..<br/> <blockquote> <div id='rewrite-rule-deny-with-style' class='blockquote'> <div class='codetop'> deny with style! </div> <div class='codeblock'> <span class='code-comment'># users can load only "special.zip", and the css and js files.</span><br/> Options +FollowSymlinks<br/> RewriteEngine On<br/> RewriteCond %{REQUEST_FILENAME} !^(.+)\.css$<br/> RewriteCond %{REQUEST_FILENAME} !^(.+)\.js$<br/> RewriteCond %{REQUEST_FILENAME} !special.zip$<br/> RewriteRule ^(.+)$ /chat/ [NC]<br/> </div> </div> </blockquote> <br/>Here we take the whole thing a stage further. Users can access .css (stylesheet) and javascript files without problem, and also the file called "special.zip", but requests for any other filetypes are immediately redirected back up to the main "/chat/" directory. You can add as many types as you need. You could also bundle the filetypes into one line using | (or) syntax, though individual lines are perhaps clearer.<br/> <br/> Here's what's currently cooking inside my <tt>/inc/</tt> directory..<br/> <br/> <blockquote> <div id='rewrite-rule-control-inc' class='blockquote'> <div class='codetop'> all-in-one control.. </div> <div class='codeblock'> RewriteEngine on<br/> Options +FollowSymlinks<br/> <span class='code-comment'># allow access with no restrictions to local machine at 192.168.1.3</span><br/> RewriteCond %{REMOTE_ADDR} !192.168.1.3<br/> <span class='code-comment'># allow access to all .css and .js in sub-directories..</span><br/> RewriteCond %{REQUEST_URI} !\.css$<br/> RewriteCond %{REQUEST_URI} !\.js$<br/> <span class='code-comment'># allow access to the files inside img/, but not a directory listing..</span><br/> RewriteCond %{REQUEST_URI} !img/(.*)\.<br/> <span class='code-comment'># allow access to these particular files...</span><br/> RewriteCond %{REQUEST_URI} !comments.php$<br/> RewriteCond %{REQUEST_URI} !corzmail.php$<br/> RewriteCond %{REQUEST_URI} !digitrack.php$<br/> RewriteCond %{REQUEST_URI} !gd-verify.php$<br/> RewriteCond %{REQUEST_URI} !post-dumper.php$<br/> RewriteCond %{REQUEST_URI} !print.php$<br/> RewriteCond %{REQUEST_URI} !source-dump.php$<br/> RewriteCond %{REQUEST_URI} !textview.php$<br/> RewriteRule ^(.*)$ / [R,NC,L]<br/> </div> </div> </blockquote> </div> <div class='small-space' id='section-more_banning'> </div> <div id='more-better-banning'> <h3>Ban User Agents, referrers, script-kiddies and more..</h3> There are many valid reasons to ban a particular request from sucking up your site's resources; resources that could be better served to valid, interested users. It might be some cross-site attack script, or inward link from a place you don't want to be associated with, or perhaps a web sucker or download manager, whatever; .htaccess + <tt>mod_rewrite</tt> provides ways to protect your content from unwanted "guests".<br/> <br/> The basic formula is standard if-then logic: <em>if</em> the request meets a particular CONDITION, <em>then</em> REWRITE the request. The "conditions" can be many things; perhaps the referrer header sent by their browser (the site they came <em>from</em>), or the page they asked for, or a particular query parameter, or the type of client (browser, etc.) they are using, or any other piece of information Apache has attached to the request. Here's an example which will deny access to "Teleport Pro", a download manager which is known to suck, hard..<br/> <br/> <blockquote> <div id='rewrite-this-sucker-to-my-abuse-page' class='blockquote'> <div class='codetop'> Who need's a local copy, when I'm right here?.. </div> <div class='codeblock'> RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [NC]<br/> RewriteRule . abuse.txt [L]<br/> </div> </div> </blockquote> <br/> It's your site, and just like your home, you have every right to exert some control over who gets in. You may have a <em>huge</em> list of user agents you'd rather not have eating your bandwidth; so use the <tt>[OR]</tt> flag, and <em>line 'em up..</em><br/> <br/> <blockquote> <div id='rewrite-suckers-to-my-abuse-page' class='blockquote'> <div class='codetop'> A little garlic for the net vampires.. </div> <div class='codeblock'> RewriteCond %{HTTP_USER_AGENT} ^BackWeb [NC,OR]<br/> RewriteCond %{HTTP_USER_AGENT} ^Bandit [NC,OR]<br/> RewriteCond %{HTTP_USER_AGENT} ^BatchFTP [NC,OR]<br/> RewriteCond %{HTTP_USER_AGENT} ^BecomeBot [NC,OR]<br/> RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [NC,OR]<br/> <span class='code-comment'># etc..</span><br/> RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [NC]<br/> RewriteRule . abuse.txt [L]<br/> </div> </div> </blockquote> <br/> This forms the basis of what often becomes a HUGE list of ban-lines. Remember, we aren't limited to user agent strings..<br/> <br/> <blockquote> <div id='rewrite-anyone-to-my-abuse-page' class='blockquote'> <div class='codetop'> Suckers, h4x0rz, kiddies, cross-site scripters and more.. Bye now! </div> <div class='codeblock'> <span class='code-comment'># why not come visit me directly?</span><br/> RewriteCond %{HTTP_REFERER} \.opendirviewer\. [NC,OR]<br/> <span class='code-comment'># this prevents stoopid cross-site discovery attacks..</span><br/> RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]<br/> <span class='code-comment'># please stop pretending to be the Googlebot..</span><br/> RewriteCond %{HTTP_REFERER} users\.skynet\.be.* [NC,OR]<br/> <span class='code-comment'># really, we need a special page for these twats..</span><br/> RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]<br/> RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]<br/> RewriteCond %{REQUEST_URI} owssvr\.dll [NC,OR]<br/> <span class='code-comment'># you can probably work these out..</span><br/> RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]<br/> RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]<br/> <span class='code-comment'># etc..</span><br/> RewriteCond %{HTTP_USER_AGENT} Sucker [NC]<br/> RewriteRule . abuse.txt [L]<br/> </div> </div> </blockquote> <br/> Fortunately, <tt>mod_rewite</tt> can parse enormous lists of ban-lines in milliseconds, so feel free to be as specific and comprehensive as required.<br/> <br/> As ever, <strong>thorough testing is strongly recommended</strong>. Simply send requests matching your conditions and see what happens. And importantly; normal requests, too. Firefox, Opera, Konqueror, and most other decent browsers, allow you to alter the user agent string; though you would quickly find the process tedious in a testing situation. Far better to use some tool better designed to send fake HTTP requests..<br/> <br/>It's not too difficult to mock up a web request on the command-line with any-old user agent using a scripting language like php or Perl, if you have these things available (read: most Linux/UNIX/BSD/etc. as well as many other <a title='Operating Systems'>OS</a>). Many examples exist online. In fact, you could quickly create a <em>suite</em> of tests, designed to interrogate all your rewrite rules, with results logging and much more, if required. <a id='link-external-cURL' title='groks those URLs, apparently.' href='http://curl.haxx.se/'>cURL</a> is always useful for jobs like this, so long as you don't add a cURL ban-line!<br/> <br/> On a Windows desktop, <a id='link-external-Sam_Spade_Software' title='DO NOT DISABLE THE STARTUP QUOTES! That's my advice.' href='http://preview.samspade.org/ssw/'>Sam Spade</a> can send a single spoofed request with a couple of clicks, along with a stack of similarly handy tricks, and regularly proves itself invaluable.<br/> <br/> </div> <div class='small-space' id='section-prevent_hot-linking'> </div><br/> <h3>prevent hot-linking</h3> <div id='h0t71nKiN4_FuCkP1g5'> Believe it or not, there are some webmasters who, rather than coming up with their own content will <em>steal</em> yours. Really! Even worse, they won't even bother to copy to their own server to serve it up, they'll just <strong>link to your content!</strong> no, it's true, in fact, it used to be incredibly common. These days most people like to prevent this sort of thing, and .htaccess is one of the best ways to do it.<br/> <br/> This is one of those directives where the mileage variables are at their limits, but something like this works fine for me..<br/> <br/> <blockquote> <div id='rewrite-rule-prevent-hot-linking' class='blockquote'> <div class='codetop'> how DARE they! </div> <div class='codeblock'> Options +FollowSymlinks<br/> <span class='code-comment'># no hot-linking</span><br/> RewriteEngine On<br/> RewriteCond %{HTTP_REFERER} !^$<br/> RewriteCond %{HTTP_REFERER} !^http://(www\.)?corz\.org/ [NC]<br/> RewriteRule .*\.(gif|jpg|png)$ <script type='text/javascript'> // <!-- document.write("<a href=\"javascript:OpenWindow('/img/hotlink.png',233,20,370,200)\" title=\"this is what you get hot-linking to corz.org!\">http://corz.org/img/hotlink.png<\/a> [NC]") //--> // </script><a title='this is what you get hot-linking to corz.org!' href='javascript:OpenWindow('/img/hotlink.png',233,20,370,200)'>http://corz.org/img/hotlink.png</a> [NC] <noscript> <div> <a title='(opens in a new window - apple-click (shift-click on peecees) for a new tab instead)' href='/img/hotlink.png'> http://corz.org/img/hotlink.png</a> [NC]<br/> </div> </noscript> </div> </div> </blockquote> <br/>You may see the last line broken into two, but it's all one line (all the directives on this page are). Let's have a wee look at what it does..<br/> <br/> We begin by enabling the rewrite engine, as always. <br/> <br/> The first <a title=''conditions', things to and match against the rewrite rule with deal with whatever requests these 'conditions' match'>RewriteCond</a> line allows <em>direct</em> requests (not <em>from</em> other pages - an "empty referrer") to pass unmolested. The next line means; <em>if</em> the browser <em>did</em> send a referrer header, and the word "corz.org" is <em>not in the domain part of it</em>, then <em>DO</em> rewrite this request.<br/> <br/> The all-important final <a title='the magic happens here. only requests that got through all the condition statements will be processed by the rule on this line.'>RewriteRule</a> line instructs <tt>mod_rewrite</tt> to rewrite all matched requests (anything without "corz.org" in its referrer) asking for gifs, jpegs, or pngs, to an alternative image. <br/> <br/>There are loads of ways you can write this rule; Google for "hot-link protection" and get a whole heap. Simple is best. You could send a wee message instead, or direct them to some evil script, or something. Mine is a simple <tt>corz.org</tt> logo, which <em>I</em> think is rather clever. Actually, these days, I do something even <a id='link-devblog-auto-hotlink' title='It's Automatic! It's HYDROMATIC! No wait, it's not hydromatic..' href='http://corz.org/devblog/2008-dec/Auto-HotLink'>cleverer-er</a>..<br/> </div> <div class='small-space' id='section-lose_the_www'> </div><br/> <h3>lose the "www"</h3> <div id='NOWWW'> I'm often asked how I prevent the "www" part showing up at my site, so I guess I should add something about that. Briefly, if someone types http://www.corz.org/ into their browser (or uses the www part for any link at corz.org) it is redirected to the plain, rather neat, http://corz.org/ version. This is <em>very</em> easy to achieve, like this..<br/> <br/> <blockquote> <div id='rewrite-rule-no-www' class='blockquote'> <div class='codetop'> beware the regular expression: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteCond %{http_host} ^www\.corz\.org [NC]<br/> RewriteRule ^(.*)$ http://corz.org/$1 [R=301,NC]<br/> </div> </div> </blockquote> <br/>You don't need to be touched by genius to see what's going on here. There are other ways you could write this rule, but again, simple is best. Like most of the examples here, the above is pasted directly from my own main .htaccess file, so you can be sure it works perfectly. In fact, I recently updated it so that I could share rules between my dev mirror and live site without any .htaccess editing..<br/> <br/> <blockquote> <div id='rewrite-rule-no-www-better' class='blockquote'> <div class='codetop'> here's what I'm currently using: </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]<br/> RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]<br/> </div> </div> </blockquote> </div> <div class='small-space' id='section-rewrite_sub-domains'> </div><br/> <h3>multiple domains in one root</h3> <div id='mod_rewrite-domains'> If you are in the unfortunate position of having your sites living on a host that doesn't support multiple domains, you may be forced to roll your own with <tt>.htaccess</tt> and <tt>mod_rewrite</tt>. So long as your physical directory structure is well thought-out, this is fairly simple to achieve.<br/> <br/> For example, let's say we have two domains, pointing at a single hosted root; <tt>domain-one.com</tt> and <tt>domain-two.com</tt>. In our web server root, we simply create a folder for each domain, perhaps <tt>one/</tt>, and <tt>two/</tt> then in our main (root) <tt>.htaccess</tt>, rewrite all incoming requests, like this..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> All requests NOT already rewritten into these folders, transparently rewrite.. </div> <div class='codeblock'> <code><span class='code-comment'>#two domains served from one root..</span><br/> RewriteCond %{HTTP_HOST} domain-one.com<br/> RewriteCond %{REQUEST_URI} !^/one<br/> RewriteRule ^(.*)$ one/$1 [L]<br/> <br/> RewriteCond %{HTTP_HOST} domain-two.com<br/> RewriteCond %{REQUEST_URI} !^two<br/> RewriteRule ^(.*)$ two/$1 [L]<br/> </code> </div> </div> </blockquote><br/> All requests for the host <tt>domain-one.com</tt> are rewritten (not R=redirected) to the <tt>one/</tt> directory, so long as they haven't already been rewritten there (the second <tt>RewriteCond</tt>). Same story for <tt>domain-two.com</tt>. Note the inconsistency in the RewriteCond statement; <tt>!^/dir-name</tt> and <tt>!^dir-name</tt> should both work fine.<br/> <br/>Also note, with such a simple domain & folder naming scheme, you could easily merge these two rule sets together. This would be unlikely in the real world though, which is why I left them separate; but still, worth noting.<br/> <br/> Other general settings and php directives can also go in this root <tt>.htaccess</tt> file, though if you have any further rewrite you'd like to perform; short URL's, htm to php conversion and what-not; it's probably easier and clearer to do those inside the sub-directory's .htaccess files.<br/></div> <div class='tiny-space' id='section-auto-translation'> </div><br/> <h3>automatic translation</h3> <div id='auto-translate'> If you don't read English, or some of your guests don't, here's a neat way to have the wonderful Google translator provide automatic on-the-fly translation for your site's pages. Something like this..<br/> <br/> <blockquote> <div id='rewrite-rule-auto-translation-ORIGINAL' class='blockquote'> <div class='codetop'> they simply add their country code to the end of the link, or <em>you</em> do.. </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.*)-fr$ http://www.google.com/translate_c?hl=fr&sl=en&u=http://corz.org/$1 [R,NC]<br/> RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://corz.org/$1 [R,NC]<br/> RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://corz.org/$1 [R,NC]<br/> RewriteRule ^(.*)-it$ http://www.google.com/translate_c?hl=it&sl=en&u=http://corz.org/$1 [R,NC]<br/> RewriteRule ^(.*)-pt$ http://www.google.com/translate_c?hl=pt&sl=en&u=http://corz.org/$1 [R,NC]<br/> </div> </div> </blockquote> <br/> You can create your menu with its flags or whatever you like, and add the country code to end of the links.. <tt><a href="page.html-fr" id="... </tt> <a id='french-version' title='Automatic Translation courtesy of the ever-wonderful Google' rel='nofollow' href='http://corz.org/serv/tricks/htaccess2.php-fr'>Want to see this page in French</a>?<br/> <br/>Although it is very handy, and I've been using it here for a couple of years here at the org, for my international blog readers, all two of them, heh. Almost no one knows about it, mainly because I don't have any <em>links</em> . One day I'll probably do a wee toolbar with flags and what-not. Perhaps not. Trouble is, the Google translator stops translating after a certain amount of characters (which seems to be increasing, good), though these same rules could easily be applied to other translators, and if you find a good one, one that will translate a really <em>huge</em> document on-the-fly, do let me know!<br/> <br/>If you wanted to be really clever, you could even perform some some kind of IP block check and present the correct version automatically, but that is outside the scope of this document. note: this may be undesirable for pages where technical commands are given (like this page) because the commands will also be translated. "RewriteEngine dessus" will almost certainly get you a 500 error page!<br/> <br/>Another thing you might like to try; rather than individual country flags; fr, de, etc., use the "u" flag, for "Universal". In theory, Google will check the client's location, and automatically translate to <em>that</em> language. One line in your .htaccess would cover all languages, and automatically cover new ones as Google adds them.<br/> <br/>While I'm here, slightly related; if you are non-english speaking, note, you can do a similar thing browser-side, create a "bookmarklet" (a regular bookmark, except that it "does something"), using this code for the location.. <blockquote> <div id='rewrite-rule-auto-translation-from-browser' class='blockquote'> <div class='codetop'> the same sort of thing, except browser-side.. </div> <div class='codeblock'> javascript:void(location.href='http://translate.google.com/translate?u='+location.href)<br/> </div> </div> </blockquote> <br/> </div> <div class='small-space'> </div> <h3>httpd.conf</h3> <div id='subfolderrulesok'> Remember, if you put these rules in the main server conf file (usually httpd.conf) rather than an .htaccess file, you'll need to use <strong>^/...</strong> ... instead of <strong>^...</strong> ... at the beginning of the RewriteRule line, in other words, add a slash.<br/> </div> <div class='small-space' id='section-inheritance'> </div><br/> <h3>inheritance..</h3> <div id='inheritance'> If you are creating rules in sub-folders of your site, you need to read this.<br/> <br/> You'll remember how rules in top folders apply to all the folders <em>inside</em> those folders too. we call this "inheritance". normally this just works. <strong>but</strong> if you start creating other rules inside subfolders you will, in effect, obliterate the rules already applying to that folder due to inheritance, or "decendancy", if you prefer. not <em>all</em> the rules, <em>just the ones applying to that subfolder</em>. a wee demonstration..<br/> <br/> Let's say I have a rule in my main <code>/.htaccess</code> which redirected requests for files ending .htm to their .php equivalent, just like the example at the top of this very page. now, if for any reason I need to add some rewrite rules to my <code>/osx/.htaccess</code> file, the .htm >> .php redirection will no longer work for the <code>/osx/</code> subfolder, I'll need to reinsert it, <em>but with a <span style='color: rgb(248, 29, 0);'>crucial</span> difference</em>..<br/> <br/> <blockquote> <div id='rewrite-rule-inheritance-cascading' class='blockquote'> <div class='codetop'> this works fine, site-wide, in my main .htaccess file </div> <div class='codeblock'> <span class='code-comment'># main (top-level) .htaccess file..</span><br/> <span class='code-comment'># requests to file.htm goto file.php</span><br/> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule ^(.*)\.htm$ http://corz.org/$1.php [R=301,NC]<br/> </div> </div> </blockquote> <br/> Here's my updated <code>/osx/.htaccess</code> file, with the .htm >> .php redirection rule reinserted..<br/> <br/> <blockquote> <div id='rewrite-rule-subfolder-rules' class='blockquote'> <div class='codetop'> but I'll need to reinsert the rules for it to work in this sub-folder </div> <div class='codeblock'> <span class='code-comment'># /osx/.htaccess file..</span><br/> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteRule some rule that I need here<br/> RewriteRule some other rule I need here<br/> RewriteRule ^(.*)\.htm$ http://corz.org/<span style='color: rgb(248, 29, 0);'>osx/</span>$1.php [R=301,NC]<br/> </div> </div> </blockquote> <br/> Spot the difference in the subfolder rule, highlighted in <span style='color: rgb(248, 29, 0);'>red</span>. you <strong>must</strong> add the current path to the new rule. now it works again, and all the osx/ subfolders will be covered by the new rule. if you remember this, you can go replicating rewrite rules all over the place.<br/> <br/> If it's possible to put your entire site's rewrite rules into the main .htaccess file, and it probably is; do that, instead, like this.. <br/> <br/> <blockquote> <div id='rewrite-rule-all-in-one' class='blockquote'> <div class='codetop'> it's a good idea to put all your rules in your main .htaccess file.. </div> <div class='codeblock'> <span class='code-comment'># root /.htaccess file..</span><br/> Options +FollowSymlinks<br/> RewriteEngine on<br/> <span class='code-comment'># .htm >> .php is now be covered by our main rule, there's no need to repeat it. </span><br/> <span class='code-comment'># But if we do need some /osx/-specific rule, we can do something like this..</span><br/> RewriteRule ^<span style='color: rgb(248, 29, 0);'>osx/</span>(.*)\.foo$ <a title='normally, there's no need to specify the full URL.'>/</a><span style='color: rgb(248, 29, 0);'>osx/</span>$1.bar [R=301,NC]<br/> </div> </div> </blockquote> <br/> Note, no full URL (with domain) in the second example. Don't let this throw you; with or without is functionally identical, on <em>most</em> servers. Essentially, try it without the full URL first, and if that doesn't work, sigh, and add it - maybe on your next host!<br/> <br/>The latter, simpler form is preferable, if only for its tremendous portability it offers - my live site, and my development mirror share the exact same .htaccess files - a highly desirable thing.<br/> <br/> By the way, it perhaps doesn't go without saying that if you want to <em>disable</em> rewriting inside a particular subfolder, where it is <em>enabled</em> further up the tree, simply do:<br/> <br/> <blockquote> <div id='rewrite-rule-disable-rewriting-in-here' class='blockquote'> <div class='codetop'> handy for avatar folders, to allow hot-linking, etc.. </div> <div class='codeblock'> RewriteEngine <a id='mod_rewrite_OFF' title='using 'on', would also work, but with a slight performance penalty. Also, it's silly.'>off</a> </div> </div> </blockquote> </div> <div class='small-space' id='section-cookies'> </div><br/> <h3>cookies</h3> <div id='cookies-in-htaccess'> Lastly, a quick word about cookies. While it's easy enough to set cookies in .htaccess without any <tt>mod_rewrite</tt>..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> create a cookie called "example-cookie", and set its value to "true".. </div> <div class='codeblock'> Header set Set-Cookie "example-cookie=true"<br/> </div> </div> </blockquote><br/> ..you <em>will</em> need it to read the cookie information back again, and "do stuff" with it. It's easy. For example, to check if the above cookie exists and has the correct value set, we could simply do..<br/> <br/> <blockquote> <div class='blockquote'> <div class='codetop'> check for that same cookie + value.. </div> <div class='codeblock'> Options +FollowSymlinks<br/> RewriteEngine on<br/> RewriteCond %{HTTP_COOKIE} !corz-tools=true<br/> RewriteRule .* /err/401.php<br/> </div> </div> </blockquote><br/>..which could easily form the basis of a simple authentication system. As with any RewriteCond, you can get pretty complex, checking multiple cookies, utilizing regexp and more, but that's enough to get you started. </div> <div class='small-space' id='section-conclusion'> </div><br/> <h3>conclusion</h3> <div id='summinup'> In short, <tt>mod_rewrite</tt> allows you to send browsers <em>from</em> anywhere <em>to anywhere</em>. You can create rules based not simply on the requested URL, but also on such things as IP address, browser agent (send old browsers to different pages, for instance), and even the time of day; the possibilities are practically limitless.<br/> <br/> The ins-and outs of <tt>mod_rewrite</tt> syntax are topic for a <em>much</em> longer document than this, and if you fancy experimenting with more advanced rewriting rules, I urge you to check out the apache documentation. <br/> <br/> If you have apache installed on your system, there will likely be a copy of the apache manual, <a onclick='window.open(this.href); return false;' title='oh what a clever puter you've got! (opens in a new window - apple-click (shift-click on peecees) for a new tab instead)' href='http://localhost/manual/'>right here</a>, and the excellent mod_rewriting guide, <a title='aye, there's loads of stuff like this hidden in yer puter! (opens in a new window - apple-click (shift-click on peecees) for a new tab instead)' href='http://localhost/manual/misc/rewriteguide.html' onclick='window.open(this.href); return false;'>lives right here</a>. do check out the <a title='the syntax stuff lives here (opens in a new window - apple/shift-click for a new tab/window)' onclick='window.open(this.href); return false;' href='http://localhost/manual/mod/mod_rewrite.html'>URL Rewriting Engine notes</a> for the juicy syntax bits. That's where I got the cute quote for the top of the page, too.<br/></div> <div class='small-space'> </div> <div id='ceeya'> ;o)<br/> <a href='mailto:please-use-my-gmail-account-ta?subject=htaccess2.php'>(or</a><br/></div> <div class='quarter-space'> </div> <div class='tiny-space' id='section-troubleshooting'> </div><br/> <h3>troubleshooting tips..</h3> <h4>rewrite logging..</h4> When things aren't working, you may want to enable rewrite logging. I'll assume you are testing these <tt>mod_rewrite</tt> directives on your development mirror, or similar setup, and can access the main <tt>httpd.conf</tt> file. If not, <em>why not?</em> Testing <tt>mod_rewrite</tt> rules on your live domain isn't exactly ideal, is it? Anyway, put this somewhere at the foot of your <tt>http.conf</tt>..<br/> <br/> <blockquote> <div id='rewrite-rule-logging' class='blockquote'> <div class='codetop'> Expect large log files.. </div> <div class='codeblock'> <span class='code-comment'>#</span><br/> <span class='code-comment'># ONLY FOR TESTING REWRITE RULES!!!!!</span><br/> <span class='code-comment'>#</span><br/> RewriteLog "/tmp/rewrite.log"<br/> <span class='code-comment'>#RewriteLogLevel 9</span><br/> RewriteLogLevel 5<br/> </div> </div> </blockquote> <br/>Set the file location and logging level to suit your own requirements. If your rule is causing your Apache to loop, load the page, immediately hit your browser's "STOP" button, and then restart Apache. All within a couple of seconds. Your rewrite log will be full of all your diagnostic information, and your server will carry on as before.<br/> <br/> Setting a value of 1 gets you almost no information, setting the log level to 9 gets you GIGABYTES! So you <strong>must</strong> remember to comment out these rules and restart Apache when you are finished because, not only will rewrite logging create space-eating files, it will seriously impact your web server's performance. <br/> <br/> <tt>RewriteLogLevel 5</tt> is very useful, but 2 is probably enough information for most issues.<br/> <br/> <h4>Fatal Redirection</h4> If you start messing around with 301 redirects [R=301], aka. "Permanently Redirected", and your rule isn't working, you could give yourself some serious headaches..<br/> <br/> Once the browser has been redirected <em>permanently</em> to the wrong address, if you then go on to alter the wonky rule, your browser will <em>still</em> be redirected to the old address (because it's a browser thing), and you may even go on to fix, <em>and then break</em> the rule all over again without ever knowing it. Changes to 301 redirects can take a long time to show up in your browser.<br/> <br/> <strong>Solution</strong>: restart your browser, or use a different one.<br/> <br/> <strong>Better Solution</strong>: Use [R] instead of [R=301] <em>while you are testing</em> . When you are 100% certain the rule does exactly as it's expected to, <em>then</em> switch it to [R=301] for your live site.<br/> <div class='tiny-space' id='section-debug-report.php'> </div><br/> <h4><big><tt>debug-report.php</tt></big><br/> <small>A php script to make your mod_rewrite life easier!</small></h4> When things aren't working as you would expect, you probably won't have to enable rewrite logging to get the information you need. What's usually required is no more than a quick readout of all the current variables, <tt>$_GET</tt> array, and so on; so you can see <em>exactly</em> what happened to the request. <br/> <br/> For another purpose, I long ago created <tt>debug.php</tt>, and later, finding all this information useful in chasing down wonky rewrites, created a "report" version, which rather than output to a file, spits the information straight back into your browser, as well as <tt>$_POST</tt>, <tt>$_SESSION</tt>, and <tt>$_SERVER</tt> arrays, special variables, like <tt>__FILE__</tt>, and much more. <br/> <br/> Usage is simple; you make it your <em>target page</em>, so in a rule like this..<br/> <br/> <blockquote> <div id='test-your-rules-with-debug-report-php' class='blockquote'> <div class='codeblock'> RewriteRule ^(.*)\.html$ /catch-all.php?var=$1<br/> </div> </div> </blockquote> <br/> You would have a copy of <tt>debug-report.php</tt> temporarily renamed to <tt>catch-all.php</tt> in the root of your server, and type <tt>http://testdomain.org/foobar.html</tt> into your address bar and, with yer mojo working, <tt>debug-report.php</tt> leaps into your browser with a shit-load of <em>exactly</em> the sort of information you need to figure out all this stuff. When I'm messing with <tt>mod_rewrite</tt>, <tt>debug-report.php</tt> saves me time, a lot. Also, it's free..<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=ae909c42-0367-8c37-826e-a38012bc7f52' alt='' class='zemanta-pixie-img'/></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-77489979207646747082009-07-24T09:36:00.002+07:002009-07-28T09:44:33.144+07:00Saving changes is not permitted<div xmlns='http://www.w3.org/1999/xhtml'>Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.<br/><br/><a href='http://www.richptc.com/index.php?ref=coolhake'><img border='0' src='http://richptc.com/earnBanner.php?username=coolhake'/></a><br/><br/><a href='http://www.bigmoneyptc.com/index.php?ref=coolhake'><img border='0' src='http://www.bigmoneyptc.com/banners/banner2.png'/></a><br/><br/><a href='http://cashmails.org/pages/index.php?refid=coolhake'><img border='0' src='http://www.cashmails.org/pages/images/468x60.gif' alt='cashmails.org'/></a><br/><br/><a href='http://www.creativemails.biz/pages/index.php?refid=coolhake'><img border='0' src='http://www.creativemails.biz/images/banner.gif' alt='creativemails.biz'/></a><br/><br/>By default SSMS 2008 does not allow you to save changes that result in a drop/create. To change this setting, go to Tools->Options->Desginers menu and uncheck the option 'Prevent saving changes that require table re-creation'.<br/><br/><a href='http://instantptr.com/pages/index.php?refid=coolhake'><img border='0' src='http://www.instantptr.com/images/banner2.gif' alt='instantptr.com'/></a><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=913f6376-c78b-8c81-bd4d-13a1fb283e9c' alt='' class='zemanta-pixie-img'/></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-47335353152705130632008-09-29T20:46:00.001+07:002009-07-23T22:13:09.402+07:00Solving the "Operation must use an updateable query" error<p class="abstract"> This unbelievably cryptic error is the bane of developers who are just starting out with Access and ASP.NET. You've done your code, plopped your database file in the App_Data folder, and try to run a page that INSERTs or UPDATEs records, and it all stops dead. This brief article explains the cause of the error, and the steps required to stop it recurring.<br /></p><p class="abstract"><a href="http://www.richptc.com/index.php?ref=coolhake"><img src="http://www.richptc.com/banners/banner1.png" border="0" /></a><br /></p> <p>When a Jet 4.0 database (the actual type of database represented by your "Access" mdb file) is deployed in a multi-user environment, an .ldb file is created whenever the database is opened. The .ldb file contains details which include who has opened the file, and primarily serves to prevent opened records being written to by another user.</p> <p>In the context of an ASP.NET application, who the "user" is will depend on the platform: for XP Pro machines, the user is the ASPNET account. On Windows Server 2003 and Vista, it is the NETWORK SERVICE account. However, if you have <a href="http://msdn.microsoft.com/en-us/library/aa292118%28VS.71%29.aspx">ASP.NET Impersonation</a> enabled, the user account will be IUSR_<em>machinename</em>. To be able to create, write to and delete the required .ldb file, the relevant user needs <strong>MODIFY</strong> permissions on the <strong>folder</strong> that the .mdb file is in.</p> <p>To set this permission, right click on the App_Data folder and select Properties. Look for the Security tab. If you can't see it, you need to go to My Computer, then click Tools and choose Folder Options.... then click the View tab. Scroll to the bottom and uncheck "Use simple file sharing (recommended)". Back to the Security tab, you need to add the relevant account to the Group or User Names box. Click Add.... then click Advanced, then Find Now. The appropriate account should be listed. Double click it to add it to the Group or User Names box, then check the Modify option in the permissions. That's it. You are done.</p> <p><strong>Note</strong>: this fix will also solve "<em>The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data</em>" errors.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-14184433115639824212008-09-25T14:32:00.001+07:002008-09-25T14:32:31.980+07:00Improving the Firefox experience<div xmlns='http://www.w3.org/1999/xhtml'>There are a few things you can do to improve your browsing experience.<br />First of all the most important one, press F11 to maximize the viewing<br />area! In Firefox 3 everything will disappear, even the navigation bar<br />at the top. Moving the cursor towards the few remaining pixels brings<br />it back, beautiful. If you prefer to have it visible all the time enter<br />about:config in the address bar and change browser.fullscreen.autohide<br />to false.<br/><br/>The only thing that's been bothering me with the full<br />screen mode is the lack of the status bar, especially when hovering<br />over links to check the destination. The status bar can be brought<br />back. Open a terminal and launch the profile manager.<br/><br/><code><strong>/opt/firefox/firefox -profilemanager -no-remote</strong></code><br/><br/>You<br />will see the name of the profile you are currently using. Close the<br />profile manager and type the following in the terminal, substituting <strong>myprofile</strong> with the name of your profile.<br/><br/><code><strong>cd /home/user/.mozilla/firefox/*myprofile/chrome<br/>mousepad userChrome-example.css</strong></code><br/><br/>Enter the following line at the end of the file you just opened and save it.<br/><code>#status-bar {visibility: visible !important;}</code><br/><br/><code><strong>mv userChrome-example.css userChrome.css</strong></code><br/><br/>Now<br />another thing that makes browsing difficult, if you don't have a mouse,<br />is the touchpad. Especially right clicking, changing tabs and so forth.<br />Fortunately Firefox has quite a few touchpad friendly shortcuts.<br/><br/><span style='font-size: 12px;'>CTRL + LEFT CLICK » open link in a new tab<br/><br/>CTRL + T » open new tab<br/>CTRL + W » close tab<br/><br/>CTRL + N » open new window<br/>CTRL + SHIFT + W » close window<br/><br/>CTRL + TAB » switch to next tab<br/>CTRL + SHIFT + TAB » switch to previous tab<br/><br/>ALT + LEFT » back<br/>ALT + RIGHT » forward<br/><br/>CTRL + L » select address bar<br/>CTRL + K » select search bar</span><br/><br/>Mastering<br />all those shortcuts makes for a smooth and fast browsing experience. If<br />you really want to go hardcore press F7 to bring up a small cursor. Now<br />you'll barely need the touchpad at all. Makes browsing a bit tedious, i<br />wouldn't recommend it.<br/><br/>Very useful on the small screen is the<br />zoom feature. Firefox 3 zooms the whole page, keeping the layout 1:1,<br />which can lead to garbled images. Most of the time it's better to just<br />zoom the text, you can toggle this behaviour with browser.zoom.full in<br />about:config. Everything is saved for each domain individually, making<br />it really nice to customize your preferred font size.<br/><br/><span style='font-size: 12px;'>CTRL + + » Zoom In<br/>CTRL + - » Zoom Out<br/>CTRL + 0 » Default</span><br/><br/>One last thing, enter about:robots in the address bar.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-6898893542744461722008-09-25T14:19:00.001+07:002008-09-25T14:19:06.628+07:00Reclaiming disk space on the A110L<div xmlns='http://www.w3.org/1999/xhtml'><div class='post-body entry-content'><br />The A110L ships with an 8GB SSD, which in fact is only 7.51GB small.<br />And another GB is lost to the swap partition. When you boot your A110L<br />for the first time you will only have 3.6GB of free space. However up<br />to 2.2GB can be reclaimed by removing various unnecessary things or<br />simply replacing software with smaller versions. It doesn't sound like<br />much, especially in the days of TB disks, and might not seem like it's<br />worth the hassle, but with only 7.51GB it certainly is.<br/><br/>Press Alt+F2 to show the <em>Run program</em> window, check <em>Run in terminal</em> and click <em>Run</em> to open a terminal. Lets take a look at the installed packages sorted by size first.<br/><span style='font-size: 85%;'><i>You may see a connection refused error whenever you use sudo, ignore it.</i></span><br/><strong><code><br/>rpm -qa --qf "%{SIZE}\t%{NAME}\n" | sort -k1,1n<br/></code></strong><br/>You'll<br />notice ten OpenOffice language packs and a few spellchecking libraries<br />with a combined size of 367MB. Unless you're in the translation<br />business you will probably not need any of them, english is built in<br />and cannot be removed.<br/><strong><code><br/>sudo yum remove openoffice.org-langpack-it openoffice.org-langpack-ru \<br/>openoffice.org-langpack-de openoffice.org-langpack-fr openoffice.org-langpack-pt_PT \<br/>openoffice.org-langpack-es openoffice.org-langpack-nl openoffice.org-langpack-zh_TW \<br/>openoffice.org-langpack-zh_CN openoffice.org-langpack-ja_JP hunspell-it hunspell-ru \<br/>hunspell-de hunspell-es hunspell-fr hunspell-pt hunspell-nl <br/></code></strong><br/>There are also korean, chinese and japanese fonts installed, 168MB.<br/><code><strong><br/>sudo yum remove acs-firefox-fonts cjkunifonts\* taipeifonts scim-tables-chinese \<br/>baekmuk\* libhangul fonts-japanese sazanami-fonts-mincho anthy<br/></strong></code><br/>By removing all unused locales additional 172MB can be gained. Find out your locale using <strong>locale</strong>. It will show sth. like <strong>en_US.UTF8</strong>.<br />First all unused locales are removed. Then the cache is deleted and<br />rebuild only using the remaining locales. It's all automatically done<br />using the few commands below. Just replace <strong>en</strong> behind the name flag in the first line, and <strong>en_US</strong> and <strong>en_US.UTF8</strong> in the last line corresponding to your locale. You will be asked to confirm the deletion of every locale to avoid mistakes.<br/><code><strong><br/>sudo find /usr/share/locale/* -maxdepth 0 -type d -not -name en\* -ok rm -rf {} \;<br/>sudo rm /usr/lib/locale/locale-archive<br/>sudo localedef -f UTF-8 -i en_US en_US.UTF8<br/></strong></code><br/>You<br />might even get rid of OpenOffice, 240MB, completely and install<br />Abiword, only 17 MB, instead. It supports OpenDocument and can also<br />export to PDF. For your spreadsheet needs Gnumeric, 30MB, is available.<br/><strong><code><br/>sudo yum remove openoffice.org\*<br/>sudo yum install abiword gnumeric<br/></code></strong><br/>There are also alternatives to Adobe Reader, 115MB, available. Try evince and epdfview, both only a few MB small.<br/><strong><code><br/>sudo yum remove AdobeReader_enu<br/>sudo yum install evince epdfview<br/></code></strong><br/>Next in line are the Acer games, or should i say demos, with a total size of 47MB.<br/><strong><code><br/>sudo rm -rf /usr/share/games/*<br/></code></strong><br/>If<br />you want to remove the other games as well, for 46MB, try this. They<br />are listed in the order of appearance in the game menu in case you<br />still want to keep some.<br/><strong><code><br/>sudo yum remove ltris frozen-bubble tuxpuck supertux llk_linux<br/></code></strong><br/>You can also remove the Acer branded mail and messenger clients and install thunderbird and pidgin instead.<br/><strong><code><br/>sudo yum remove evolution-data-server libpurple<br/>sudo yum install thunderbird pidgin<br/></code></strong><br/>I've also removed the Acer media master, photo master and mplayer. Instead i installed <a href='http://www.videolan.org/vlc/download-fedora.html'>VLC</a>, capable of playing all formats, using the Fedora 8 installation method.<br/><strong><code><br/>sudo yum remove pdvdlinux pcmlinux mplayer\*<br/></code></strong><br/>The Online Updater will try to re-install a few things whenever a patch is available, you can find a way to prevent it <a target='_blank' href='http://macles.blogspot.com/2008/09/optional-updates-on-acer-aspire-one.html'>here</a>.<br/><br/>Whenever<br />you use yum to download and install something it will keep the<br />downloaded package in a cache, the following command sets keepcache in<br />the config file to 0 to prevent this.<br/><strong><code><br/>sudo sed -i.1 3s:1:0: /etc/yum.conf<br/></code></strong><br/>If<br />some package automatically installs a few dependent packages but<br />doesn't automatically uninstall them when the original package is<br />removed you can show the last packages installed and remove them<br />yourself.<br/><code><strong><br/>rpm -qa --last | head -n 20<br/></strong></code><strong/><br/>You can find unused libraries or packages using <strong>package-cleanup</strong>, provided by <strong>yum-utils</strong>. It is not always safe to trust package-cleanup.<br/><br/>Also<br />worth noting is that whenever you think you delete something using the<br />file browser it is moved to /home/user/.local/share/Trash instead.<br />However you can permanently delete a file using Shift+Del.<br/><br/>If you're using Firefox 3 you might have heard that <a href='http://code.google.com/apis/safebrowsing/firefox3_privacy.html'>safe browsing</a><br />has been implemented and is used by default. It does check every URL<br />you visit against a local database, which is quite big, 50MB, and will<br />grow. If you're not easily fooled by phishing websites or don't want to<br />use this feature for privacy reasons enter about:config in the address<br />bar and set both browser.safebrowsing.enabled and<br />browser.safebrowsing.malware.enabled to false. You can use the<br />following line to automatically delete the database, it will be<br />recreated with a size of 32KB. If you ever decide to re-enable both<br />options the database will be automatically rebuild.<br/><code><strong><br/>find /home/user -name urlclassifier3.sqlite -delete<br/></strong></code><br/>Unless<br />you're on a slow connection you can also disable the disk cache in<br />Firefox. Set browser.cache.disk.enable to false. Disabling both this<br />and safe browsing also reduces the frequent accessing of the SSD,<br />potentially speeding things up.<br/><br/>One more thing. If you ever get<br />the feeling that's there not enough disk space available because deep<br />down in the filesystem hierarchy some files got lost use <strong>find</strong> to track them down. Replace 100M with any size you like.<br/><strong><code><br/>sudo find / -size +100M -printf "%s %p\n" | sort -n<br/></code></strong><br/>Now<br />to the interesting part. The 1GB swap partition. If you got 1GB of RAM<br />installed you can easily disable it, even with 512MB if you're only<br />using the default applications. A booted system uses only 135MB. You<br />can check your memory usage by pressing Ctrl+Alt+Del.<br/><br/>To get that extra GB, you'll need to boot gparted from an USB stick. You can download it <a href='http://downloads.sourceforge.net/gparted/gparted-live-0.3.6-7.zip?big_mirror=no'>here</a>, instructions <a href='http://gparted.sourceforge.net/liveusb.php'>here</a>, syslinux <a href='http://www.kernel.org/pub/linux/utils/boot/syslinux/RPMS/i386/syslinux-3.70-1.i386.rpm'>here</a>. You can also use <a target='_blank' href='http://partedmagic.com/wiki/PartedMagic.php?n=PartedMagic.CreatingTheMedia'>partedmagic</a>, no difference. Remove any SD cards when booting.<br/><br/>Next prevent swap from mounting, the following command does all the work you.<br/><strong><code><br/>sudo sed -i.1 "s:/dev/sda2:#/dev/sda2:" /etc/fstab<br/></code></strong><br/>Boot<br />gparted, delete the linux-swap partition and resize the remaining one.<br />I've made some screenshots showing the progress, from left to right, of<br />the whole operation. Be warned that you might lose all your data if you<br />make some terrible mistake! The recovery tool will still work and<br />recreate both partitions and everything as it once was.<br/><br/><table cellspacing='0' cellpadding='0' border='0'><tbody><tr><td><a target='_blank' href='http://1.bp.blogspot.com/_tLunK2oc40g/SMf3jENLsvI/AAAAAAAAAJY/WRyc_Yel4t4/s1600-h/pmagic01.png'><img width='150' height='80' style='margin-right: 10px;' alt='' src='http://1.bp.blogspot.com/_tLunK2oc40g/SMf3jENLsvI/AAAAAAAAAJY/WRyc_Yel4t4/s200/pmagic01.png'/></a></td><td><a target='_blank' href='http://2.bp.blogspot.com/_tLunK2oc40g/SMf3t1Q9fyI/AAAAAAAAAJg/LXExp7J3sIY/s1600-h/pmagic02.png'><img width='150' height='80' alt='' src='http://2.bp.blogspot.com/_tLunK2oc40g/SMf3t1Q9fyI/AAAAAAAAAJg/LXExp7J3sIY/s200/pmagic02.png' style='margin-right: 10px;'/></a></td><td><a target='_blank' href='http://3.bp.blogspot.com/_tLunK2oc40g/SMf3t9aOd_I/AAAAAAAAAJo/fcP7erBMOtA/s1600-h/pmagic03.png'><img width='150' height='80' alt='' src='http://3.bp.blogspot.com/_tLunK2oc40g/SMf3t9aOd_I/AAAAAAAAAJo/fcP7erBMOtA/s200/pmagic03.png' style='margin-right: 10px;'/></a></td><td><a target='_blank' href='http://2.bp.blogspot.com/_tLunK2oc40g/SMf3uAhQYvI/AAAAAAAAAJw/q7bLJI1mvm4/s1600-h/pmagic04.png'><img width='150' height='80' alt='' src='http://2.bp.blogspot.com/_tLunK2oc40g/SMf3uAhQYvI/AAAAAAAAAJw/q7bLJI1mvm4/s200/pmagic04.png'/></a></td></tr></tbody></table><br /><br /></div></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-8209353169859374935.post-41660014216069407722008-09-25T13:47:00.001+07:002008-09-25T13:47:23.327+07:00Upgrading to OpenOffice 2.4 on Acer Aspire One Linux<div xmlns='http://www.w3.org/1999/xhtml'>The AA1 ships with OpenOffice 2.3, with no available upgrade path,<br />because 2.4 is only supported in Fedora 9, while the AA1 is based on<br />Fedora 8. There is a solution besides downloading the tar archive from<br />their website, but it requires some work. You can take a look at the <a href='http://development.openoffice.org/releases/2.4.0.html'>release notes</a> for 2.4 first to see if it's worth your time.<br/><br/>First of all remove all unnecessary language packs as described <a href='http://macles.blogspot.com/2008/07/reclaiming-disk-space-on-acer-aspire.html'>here</a>,<br />it makes upgrading much easier. Then some packages have to be<br />downloaded. Create a directory in Downloads, name it OpenOffice, and<br />save all files there.<br/><br/>The packages needed are <a href='http://koji.fedoraproject.org/packages/openoffice.org/2.4.1/17.6.fc9/i386/openoffice.org-calc-2.4.1-17.6.fc9.i386.rpm'>calc</a>, <a href='http://koji.fedoraproject.org/packages/openoffice.org/2.4.1/17.6.fc9/i386/openoffice.org-core-2.4.1-17.6.fc9.i386.rpm'>core</a>, <a href='http://koji.fedoraproject.org/packages/openoffice.org/2.4.1/17.6.fc9/i386/openoffice.org-impress-2.4.1-17.6.fc9.i386.rpm'>impress</a>, <a href='http://koji.fedoraproject.org/packages/openoffice.org/2.4.1/17.6.fc9/i386/openoffice.org-writer-2.4.1-17.6.fc9.i386.rpm'>writer</a>, <a href='http://koji.fedoraproject.org/packages/writer2latex/0.5/3.fc9/i386/openoffice.org-writer2latex-0.5-3.fc9.i386.rpm'>latex</a>, <a href='http://koji.fedoraproject.org/packages/hunspell/1.2.1/7.fc9/i386/hunspell-1.2.1-7.fc9.i386.rpm'>hunspell</a>, <a href='http://koji.fedoraproject.org/packages/hyphen/2.3.1/2.fc9/i386/hyphen-2.3.1-2.fc9.i386.rpm'>hyphen</a>, <a href='http://koji.fedoraproject.org/packages/hyphen/2.3.1/2.fc9/i386/hyphen-en-2.3.1-2.fc9.i386.rpm'>hyphen-en</a>, <a href='http://koji.fedoraproject.org/packages/mythes-en/3.0/1.fc9/noarch/mythes-en-3.0-1.fc9.noarch.rpm'>mythes-en</a>, <a href='http://koji.fedoraproject.org/packages/nspr/4.7.1/0.8.1.fc8/i386/nspr-4.7.1-0.8.1.fc8.i386.rpm'>nspr</a> and <a href='http://koji.fedoraproject.org/packages/nss/3.12.1.0/1.fc8/i386/nss-3.12.1.0-1.fc8.i386.rpm'>nss</a>. Also needed is the language package, for english being <a href='http://koji.fedoraproject.org/packages/openoffice.org/2.4.1/17.6.fc9/i386/openoffice.org-langpack-en-2.4.1-17.6.fc9.i386.rpm'>langpack-en</a>. If you need another language you'll have to edit the download path and replace <b>en</b> with your language code. All available languages can be seen <a href='http://koji.fedoraproject.org/koji/buildinfo?buildID=60482'>here</a>. Download the corresponding version of <a href='http://koji.fedoraproject.org/koji/search?match=glob&type=package&terms=hunspell*'>hunspell</a>, <a href='http://koji.fedoraproject.org/koji/search?match=glob&type=package&terms=hyphen*'>hyphen</a> and <a href='http://koji.fedoraproject.org/koji/search?match=glob&type=package&terms=mythes*'>mythes</a> in addition to the english ones. If in doubt which one to choose get the latest fc9 version available.<br/><br/>Now go into the terminal.<br/><br/><code><strong>cd Downloads/OpenOffice<br/>sudo rpm -U *rpm</strong></code><br/><br/>If<br />you only receive two errors, about libcrypto.so.7 and libssl.so.7, all<br />went well and you can continue. If not make sure you downloaded all<br />required packages and retry.<br/><br/><code><strong>sudo ln -s /lib/libcrypto.so.6 /lib/libcrypto.so.7<br/>sudo ln -s /lib/libssl.so.6 /lib/libssl.so.7</strong></code><br/><br/>Upgrading<br />OpenOffice also replaces all icons with low resolution official icons,<br />so the original ones need to be backed up. Don't forget the dot at the<br />end of the line.<br/><br/><code><strong>sudo cp /usr/share/icons/hicolor/48x48/apps/openofficeorg* .</strong></code><br/><br/>Now everything can be installed.<br/><br/><code><strong>sudo rpm -U --force --nodeps *rpm</strong></code><br/><br/>Put the original icons back in place.<br/><br/><code><strong>sudo cp openofficeorg* /usr/share/icons/hicolor/48x48/apps<br/>sudo gtk-update-icon-cache -f /usr/share/icons/hicolor</strong></code><br/><br/>The only thing left to do is to edit the desktop files, and to remove <b>%U</b> on line number nine.<br/><br/><code><strong>sudo mousepad /usr/share/applications/openoffice.org-1.9-writer.desktop<br/>sudo mousepad /usr/share/applications/openoffice.org-1.9-calc.desktop<br/>sudo mousepad /usr/share/applications/openoffice.org-1.9-impress.desktop</strong></code><br/><br/>That's it, OpenOffice has been upgraded to version 2.41, the latest available.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-40147942619142635472008-09-25T11:01:00.000+07:002008-09-25T11:01:00.953+07:00Dependency problems on Acer Aspire One Linux<div xmlns='http://www.w3.org/1999/xhtml'>As you may already know the AA1 comes with a custom version of Linpus<br />Linux, which is a custom version of Fedora. If you take a look at the<br />source <a href='ftp://guest@csdftp.acer.com.tw/Aspire_One_Linpus_Linux/Aspire_One_Srpms/'>RPMs</a> provided by Acer you will notice about 50 modified packages, recognizable by an <span style='font-weight: bold;'>lp</span><br />suffix in their filename. I have already found one package modified<br />directly by Acer where the original filename was not modified, so there<br />may be more. And since neither Acer nor Linpus keep their own<br />repositories the only choice is to use the Fedora ones if you want to<br />update or install a package. As a result you'll run into dependency<br />problems now and then.<br/><br /><br/><br />I will try to resolve them as i stumble upon them.<br/><br /><br/><br /><span style='font-weight: bold; font-size: 150%;'>#1</span> gecko-libs<br/><br />You will receive the following error whenever you try to install a<br />package that is somehow related to Firefox, or more precisely its gecko<br />engine: <span style='font-style: italic;'>Missing Dependency: gecko-libs = 1.8.1.16</span>. A package that triggers it is <span style='font-weight: bold;'>epiphany</span>.<br />It can be resolved. First of all Firefox 2 has to be removed, which can<br />only be done via rpm, or else half the system will go with it. Forcing<br />it via rpm however breaks a few packages. To satisfy their needs a<br />Fedora version of Firefox 2 is installed and a symlink to the excpected<br />library path created. Finally yelp is updated, and that's it.<br/><br /><br/><br /><code><strong>sudo rpm -e --nodeps firefox<br/><br />sudo yum install firefox<br/><br />sudo ln -s /usr/lib/firefox-2.0.0.16/* /usr/lib/mozilla<br/><br />sudo yum install yelp</strong></code><br/><br /><br/><br /><span style='font-weight: bold; font-size: 150%;'>#2</span> notification-daemon-xfce<br/><br />It manifests itself via the following message: <span style='font-style: italic;'>notification-daemon-xfce conflicts with notify-daemon</span>. The good news is that for most packages the problem is fixed with procedure <span style='font-weight: bold;'>#1</span>. I can only trigger it now via <span style='font-weight: bold;'>sudo yum update</span>,<br />which is not recommended anyway because it will turn your system into<br />Fedora 8 if you're lucky or break it if you're not. Use yum only to<br />update selected packages, and even then make sure it's not updating one<br />of the modified ones. I'll put this one hold until another package<br />complains about it.<br/><br /><br/><br /><span style='font-weight: bold; font-size: 150%;'>#3</span> gnome-menus<br/><br />This depedency problem is triggered via <span style='font-weight: bold;'>f-spot</span> or <span style='font-weight: bold;'>evolution</span>, displaying the following error message.<br/><br /><br/><br /><span style='font-style: italic;'>file<br />/usr/share/desktop-directories/Internet.directory from install of<br />gnome-menus-2.20.3-1.fc8 conflicts with file from package<br />xfdesktop-acer-lp-1522.no_spot.mcs_patched<br/><br />file /usr/share/desktop-directories/Settings.directory from install of<br />gnome-menus-2.20.3-1.fc8 conflicts with file from package<br />xfdesktop-acer-lp-1522.no_spot.mcs_patched</span><br/><br /><br/><br />It's fairly easy to fix. Just download gnome-menus and redhat-menus and<br />force their installation. Then restore the original content of the<br />conflicting files.<br/><br /><br/><br /><code><strong>sudo yum install yum-utils<br/><br />sudo yumdownloader gnome-menus redhat-menus<br/><br />cp /usr/share/desktop-directories/* .<br/><br />sudo rpm -U --force gnome*rpm redhat*rpm<br/><br />sudo mv *.directory /usr/share/desktop-directories</strong></code><br/><br /><br/><br /><span style='font-weight: bold; font-size: 150%;'>#4</span> gtk2-devel<br/><br />Not really a dependency problem but more of a general problem.<br />Installing gtk2-devel automatically updates the custom gtk2, which<br />breaks the desktop. Just download it and force the installation via rpm.<br/><br /><br/><br /><code><strong>sudo yum install yum-utils<br/><br />sudo yumdownloader --disablerepo=updates,updates-newkey gtk2-devel<br/><br />sudo rpm --force --nodeps -i gtk2-devel*rpm</strong></code><br/><br /><br/><br /><span style='font-weight: bold; font-size: 150%;'>#5</span> libpulse<br/><br />This problem only occured recently and is triggered if you try to install VLC, with the following error message.<br/><br /><br/><br /><span style='font-style: italic;'>Error: Missing Dependency: libpulse.so.0(PULSE_0) is needed by package vlc<br/><br />Error: Missing Dependency: libopendaap.so.0 is needed by package vlc-core<br/><br />Error: Missing Dependency: libdvdnav.so.4 is needed by package vlc-core</span><br/><br /><br/><br />An explanation can be found <a href='http://macles.blogspot.com/2008/09/updated-repositories.html'>here</a>, the solution is to simply use the line below.<br/><br /><br/><br /><code><strong>sudo yum install fedora-release</strong></code></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-8209353169859374935.post-72597885831947645142008-09-09T22:26:00.001+07:002008-09-09T22:26:42.421+07:00Installing Windows XP from USB<div xmlns='http://www.w3.org/1999/xhtml'><h2>Case In Point</h2><br /><p>You’ve got this <a href='http://www.acer.com/'>Acer</a> laptop with a<br />malfunctioning DVD drive. Specifically, you removed it from its bay and<br />now Windows XP crashes when you plug it back in. Knowledge Base article<br /><a href='http://support.microsoft.com/?kbid=310664'>310664</a> matches it to a tee.</p><br /><p>Provided solution: update to Service Pack 1, or disable <a href='http://en.wikipedia.org/wiki/Direct_memory_access'>DMA</a> in the <a href='http://en.wikipedia.org/wiki/BIOS'>BIOS</a>. Current situation: running <a href='http://en.wikipedia.org/wiki/SP2'>SP2</a> and blessed with a “user-friendly” BIOS that doesn’t allow you to disable DMA.</p><br /><p>Your luck just ran out, but - being the geek that you are - you<br />don’t whine about it. Instead, you come up with this bright idea: let’s<br />install Linux, that’ll work some magic! And so you get <a href='http://www.gentoo.org/'>Gentoo Linux</a> installed using a home-brewn <a href='http://www.gentoo.org/doc/en/liveusb.xml'>LiveUSB</a> distribution. And much to your dismay, proper hotplugging implementation for your laptop is lacking. Curses.</p><br /><p>So finally, you call the support line to have them collect your<br />laptop for repair. One problem here: you’re betting they won’t like<br />seeing Linux boot up and, hoping to forego additional service costs,<br />it’s up to you to reinstall Windows XP.</p><br /><p>One problem here: you don’t have a working CD-ROM drive to install Windows XP off, and from experience you know that Windows XP <a href='http://blogs.msdn.com/oldnewthing/archive/2004/04/15/113811.aspx'>won’t install from an external drive</a>. Blasted!</p><br /><p>Enter the cavalry.<br/><br /><a name='disclaimer' title='disclaimer'/></p><br /><h2>Disclaimer</h2><br /><p>The procedure here is provided without any warranty or support<br />whatsoever. It worked for me and so it might for you. It also might<br />blast you and your laptop to pieces. <strong>Some of the procedures described here can wipe all of your data.</strong> Thought I’d warn you.</p><br /><p>I don’t mean to be inventive here, either. In fact, all the<br />technology has been laid out for us and is readily available. All I’m<br />doing is wrapping it all up in writing. Shouts out to everyone who<br />provided the technology!</p><br /><p>That being said, let’s get down to business.</p><br /><h2>Ground Zero: Ingredients</h2><br /><p>You’ll be needing ample space on a USB storage device like a<br />thumbdrive or external disk drive. 1 GB of storage will suffice.<br />Possibly, you could access the setup files from a network share in<br />which case you’ll only need a 256 MB thumbdrive, but I haven’t tried<br />that.</p><br /><p>Personally, I booted off a 512 MB thumbdrive and put the Windows XP<br />setup files on an external disk drive. So a combination will do just<br />fine, but just make sure that you’ve got sufficient USB ports: <strong>all USB devices will need to be plugged in and stay plugged in while we’re booted into BartPE later on!</strong></p><br /><p>You’ll also need a bunch of software, including a valid copy of<br />Windows XP. The other software components can be downloaded freely:</p><br /><ul><li><a href='http://www.nu2.nu/pebuilder/'>Bart’s Preinstalled Environment</a> (BartPE)</li><li><a href='http://www.microsoft.com/downloads/details.aspx?FamilyID=22cfc239-337c-4d81-8354-72593b1c1f43&DisplayLang=en'>Windows 2003 Server Service Pack 1</a></li></ul><br /><blockquote><p>Q: Why Windows 2003 Server Service Pack 1? I want to install XP!</p><br /><p>A: Well that’s exactly the trick, though it’s a bit technical.<br />During booting, Windows resets the USB port and loses your boot device.<br />That’s why an installation from USB normally fails. But by using<br />Windows 2003 Server’s ramdisk feature in the early phases of booting,<br />we circumvent that problem.</p><br /><p>Don’t be mislead though: you’ll be installing Windows XP all the<br />same. It’s just that we’ll be using two Windows 2003 Server files from<br />the Service Pack to do it.</p><br /><p>You can also perform a Windows 2003 Server installation using this<br />exact same procedure, save that you’ll be needing to update to Windows<br />2003 Server Service Pack 1 instead of Windows XP SP2, below. That’s<br />assuming, of course, that you’ve got a valid copy of Windows 2003<br />Server.</p></blockquote><br /><p>You will also need an already functional Windows system to prep the<br />USB disk from. In addition, your target system (the one that needs<br />reinstalling) should support booting from USB. Virtually all modern<br />ones do though.</p><br /><p>Finally, not all cheaper USB devices properly support being booted from. The <a href='http://www.911cd.net/forums/index.php?showtopic=10806'>BartPE forums</a> have a partial list of ones that don’t.</p><br /><h2>Step One: Preparing the Windows XP Setup Files</h2><br /><p>For this procedure to work correctly, you’ll need Windows XP to be<br />at Service Pack 1 or Service Pack 2. Many newer Windows XP CDs already<br />have either one included.</p><br /><p>You can check by inserting the CD-ROM and looking at the files in the top folder. There should be a file named <code>WIN51P.SP1</code> or <code>WIN51P.SP2</code>.<br />If you see either one, fast forward to step two.If there is no such<br />file, or you’ve got a SP1 CD that you would like to update to SP2,<br />proceed as follows:</p><br /><ol><li>Copy the Windows XP CD-ROM to a location on your hard drive. We’ll be assuming <code>C:\winxpcd</code>. <em>I strongly advise you to use such a vanilla CD. Users have reported strange happenings with custom XP distributions.</em></li><li>Download the <a href='http://www.microsoft.com/downloads/details.aspx?FamilyId=049C9DBE-3B8E-4F30-8245-9E368D3CDB5A&displaylang=en'>Windows XP Service Pack 2 Network Installation Package</a>.</li><li>Unpack Windows XP SP2 by running <code>WindowsXP-KB835935-SP2-ENU.exe -x</code>. Note the <code>-x</code> parameter that will allow you to specify a location to unpack to. We’ll be assuming <code>C:\winxpsp2</code>.</li><li>Integrate SP2 into the setup files by running <code>C:\winxpsp2\i386\update\update.exe /integrate:c:\winxpcd</code>.</li></ol><br /><p>If your system needs special drivers to operate, this would be the<br />time to include them (called “slipstreaming”). Doing so isn’t exactly<br />trivial and should only be necessary if you, say, require non-standard <a href='http://en.wikipedia.org/wiki/SATA'>SATA</a> support. The process is beyond the scope of this article, but fortunately <a href='http://www.google.nl/search?q=slipstreaming+drivers'>Google</a> is your friend.</p><br /><h2>Step Two: Prepping BartPE</h2><br /><p>First we’ll prep the USB drive we’ll be using for booting. This is<br />by far the largest step in the process, though it shouldn’t be<br />difficult for anyone to follow. It requires a functional Windows system.</p><br /><ol><li>Install BartPE. We’ll be assuming that you install to <code>C:\pebuilder</code>.</li><li>Unpack PE2USB to <code>C:\pebuilder</code>.</li><li>Unpack Windows 2003 SP1 by running <code>WindowsServer2003-KB889101-SP1-x86-ENU.exe -x</code> (that’s assuming that you downloaded the English version). Note the <code>-x</code> parameter that will allow you to specify a location to unpack to. We’ll be assuming <code>C:\server2003sp1</code>.</li><li>Create a folder named <code>C:\pebuilder\srsp1</code>.</li><li>Copy <code>C:\server2003sp1\i386\setupldr.bin</code> to <code>C:\pebuilder\srsp1</code>.</li><li>Expand and copy <code>ramdisk.sys</code> by running <code>expand -r C:\server2003sp1\i386\ramdisk.sy_ C:\pebuilder\srsp1</code>.</li><li>Start PE Builder from the Start Menu. Point “Source:” to the location of your Windows XP setup files containing SP1 or SP2.</li><li>Make sure the “Output:” is set to “BartPE”. <em>If using SP2:</em> go into the Plugins configuration dialog and enable “RpcSS needs to launch DComLaunch Service First - SP2 only”.</li><li>Hit “Build”.</li><li>When it’s done building, insert the USB drive you intend to boot from and run <code>C:\pebuilder\pe2usb -f [drive:]</code>, replacing [drive:] with the location of your USB drive. <strong>This will destroy any data on your USB drive!</strong><br />The drive shouldn’t be partitioned any larger than 1 GB. If it is, then<br />repartition it using Computer Management in the Control Panel.</li><li>Copy the Windows XP setup files to the USB drive (or another USB<br />device if you have insufficient space left). You’ll only need the <code>i386</code> folder.</li></ol><br /><p>If no errors occured in the process, you should now be all set to boot from USB!</p><br /><p><em>Note: it’s possible to use Windows 2003 Server as the operating<br />system to boot from, but I don’t recommend it. Many of BartPE’s<br />included utilities won’t work properly.</em></p><br /><h2>Step Three: Configuring the BIOS</h2><br /><p>You should now reboot and go into the BIOS configuration to boot<br />from USB. Instructions for doing so wildly from system to system, but<br />generally entail the following:</p><br /><ol><li>Reboot the system.</li><li>While booting (before Windows starts loading), get into the BIOS<br />configuration screen by hitting something like F1, F2, Delete or<br />Escape. Hotkey instructions are generally provided on the screen.</li><li>Go to the section that contains your boot devices.</li><li>With your USB drive plugged in, the USB drive should be listed. If<br />it isn’t, your system might not support booting from USB. Assuming that<br />it is supported (as is the case with virtually all modern hardware),<br />promote your USB drive to the primary boot device.</li><li>Exit from the BIOS configuration, saving all changes.</li></ol><br /><p>If you’re completely new to BIOS configuration, <a href='http://www.tomshardware.com/2005/09/22/bios_for_beginners/'>BIOS for Beginners</a><br />over at Tom’s Hardware might be a good primer. Be aware though, that<br />you can seriously screw up your system by providing incorrect settings!</p><br /><h2>Step Four: Booting into BartPE</h2><br /><p>Assuming that you properly configured your BIOS and your USB device<br />supports booting, BartPE should now load. Depending on the speed of<br />your USB device, this may take a while.</p><br /><p>If it isn’t working, then double-check the following before making a scene:</p><br /><ul><li>Is your BIOS properly configured for booting from the USB disk? (Is the USB device listed and does it have top priority?)</li><li>Have you correctly prepared the USB disk in step two? (Restart the procedure.)</li><li>Does your USB stick properly support being booted from? (Try another one!)</li></ul><br /><h2>Step Five: Prepping the Hard Disk</h2><br /><p>You need to make sure that your hard drive is partitioned and<br />formatted properly. Especially if you’ve had Linux or some other<br />operating system on it, you’ll need to repartition and format it.<br />BartPE contains <a href='http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/diskpart.mspx?mfr=true'>DiskPart</a> for disk partitioning and <a href='http://www.shawneelink.net/%7Ebgmiller/'>A43 File Manager</a> to format your drive.</p><br /><p>If you are sure that your hard drive is set up properly (i.e. it has<br />only run Windows, it contains a valid FAT or NTFS partition) then you<br />can safe yourself the hassle and skip this step.</p><br /><p><strong>This procedure will destroy any data on the hard drive.</strong></p><br /><p>To repartition:</p><br /><ol><li>From the Go menu, navigate to DiskPart.</li><li>Enter the commands needed to repartition your drive. For example, try the following: <code>select disk 0</code> (select the first disk), <code>clean</code> (purges the entire drive, essentially resetting it), <code>create partition primary</code> (creates a single partition from the entire disk), <code>assign</code> (assign the partition a drive letter), <code>exit</code> (quits DiskPart).</li></ol><br /><p><strong>This procedure will destroy any data on the hard drive.</strong></p><br /><p>To format:</p><br /><ol><li>From the Go menu, navigate to the A43 File Manager.</li><li>Right-click on the target drive (e.g. <code>C:</code>) and click Format. Should be self-explanatory.</li></ol><br /><h2>Step Six: Launching Windows XP Setup</h2><br /><p>With your drive all ready, you can now launch the Windows XP setup<br />with a few custom parameters. Let’s assume that the files are available<br />at <code>D:\i386</code>.</p><br /><p><em>Plugging in a device now won’t work. Remember that all USB<br />devices will need to be plugged in right from the start while using<br />BartPE.</em></p><br /><ol><li>Run <code>D:\i386\winnt32.exe /syspart:C: /tempdrive:C: /makelocalsource</code>. Replace <code>C:</code> with the drive you want to install Windows to.</li><li>Proceed with the installation. When asked to convert the<br />installation volume to NTFS, answer No. The setup program incorrectly<br />believes that your USB drive (which is formatted as FAT) needs<br />conversion.</li></ol><br /><p>The setup program will then silently close, which might make you<br />think that something went wrong. Don’t worry though. Reboot your<br />system, remove the USB drive(s) and – if all went well – you can now<br />finish setting up Windows XP. Congratulations!</p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-65402381066659798922008-09-09T08:04:00.001+07:002008-09-09T08:04:34.731+07:00Herpes Simpleks<div xmlns='http://www.w3.org/1999/xhtml'><p class='SubHead'><b>Apa <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Radang kulit akibat beberapa virus berbeda')' class='tip'>Herpes</span> Simpleks Itu?</b></p><br /><p><span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Infeksi virus yang menyebabkan luka pada kelamin atau sekitar mulut')' class='tip'>Herpes simpleks</span> berkenaan dengan sekelompok <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Kuman yang tidak dapat dilhat dengan mikroskop biasa, yang bereplikasi dalam sel yang diinfeksikannya')' class='tip'>virus</span> yang menulari manusia. Serupa dengan <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Penyakit kulit akibat virus varisela zoster')' class='tip'>herpes zoster</span> (lihat <a href='http://spiritia.or.id/li/bacali.php?lino=514'>Lembaran Informasi (LI) 514</a>), herpes simpleks menyebabkan luka-luka yang sangat sakit pada kulit. <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Keadaan atau keluhan yang menyertai infeksi atau penyakit')' class='tip'>Gejala</span><br />pertama biasanya gatal-gatal dan kesemutan/perasaan geli, diikuti<br />dengan benjolan yang membuka dan menjadi sangat sakit. Infeksi ini<br />dapat menjadi dorman (tidak aktif) selama beberapa waktu, kemudian<br />tiba-tiba menjadi aktif kembali tanpa alasan jelas.</p><br /><p><span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Virus yang menyakitkan kulit dan sistem saraf, dan menyebabkan luka beku')' class='tip'>Virus herpes simpleks</span> tipe 1 (HSV-1) adalah penyebab umum untuk luka-luka demam (<i>cold sore</i>)<br />di sekeliling mulut. HSV-2 biasanya menyebabkan herpes kelamin. Namun<br />HSV-1 dapat menyebabkan infeksi pada kelamin dan HSV-2 dapat<br />menginfeksikan daerah mulut melalui hubungan seks.</p><br /><p>HSV adalah penyakit yang sangat umum. Di AS, kurang lebih 20% orang<br />di atas usia 12 tahun terinfeksi HSV, dan diperkirakan ada satu juta<br />infeksi baru setiap tahun. <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Jumlah orang yang mengalami penyakit tertentu')' class='tip'>Prevalensi</span><br />dan kejadian di Indonesia belum diketahui. Angka prevalensi infeksi HSV<br />sudah meningkat secara bermakna selama dasawarsa terakhir. Sekitar 80%<br />orang dengan HIV juga terinfeksi herpes kelamin.</p><br /><p>Infeksi HSV-2 lebih umum pada perempuan. Di AS, kurang lebih satu<br />dari empat perempuan dan satu dari lima laki-laki terinfeksi HSV-2. HSV<br />kelamin berpotensi menyebabkan kematian pada bayi yang terinfeksi. Bila<br />seorang perempuan mempunyai herpes kelamin aktif waktu melahirkan,<br />sebaiknya melahirkan dengan <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Tindakan untuk melahirkan bayi yang meliputi mengiris dinding perut dan rahim untuk mengeluarkan bayi')' class='tip'>bedah sesar</span>.</p><br /><p>HSV paling mungkin kambuh pada orang dengan <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Sistem dalam tubuh yang seharus melindungi kita terhadap infeksi')' class='tip'>sistem kekebalan tubuh</span><br />yang lemah. Ini termasuk orang dengan HIV, dan siapa pun berusia di<br />atas 50 tahun. Beberapa ilmuwan juga berpendapat bahwa penyakit lebih<br />mungkin kambuh pada orang yang sangat lelah atau mengalami banyak stres.</p><br /><p class='SubHead'><b>HSV dan HIV</b></p><br /><p>HSV tidak termasuk infeksi yang mendefinisikan AIDS. Namun orang<br />yang terinfeksi dengan HIV dan HSV bersama biasanya mengalami jangkitan<br />herpes kambuh lebih sering. Jangkitan ini dapat lebih parah dan<br />bertahan lebih lama dibanding dengan orang HIV-negatif.</p><br /><p>Luka akibat herpes menyediakan jalur yang dimanfaatkan HIV untuk<br />melewati pertahanan kekebalan tubuh, sehingga menjadi lebih mudah<br />terinfeksi HIV. Sebuah penelitian baru menemukan bahwa orang dengan HSV<br />mempunyai risiko terinfeksi HIV tiga kali lebih tinggi dibandingkan<br />orang tanpa HSV. Sebuah penelitian lain menemukan bahwa mengobati HSV<br />dapat mengakibatkan penurunan yang bermakna pada <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Jumlah virus (misalnya HIV atau HCV) di dalam aliran darah')' class='tip'>viral load</span> HIV.</p><br /><p>Orang dengan HIV dan HSV bersama juga sebaiknya sangat hati-hati<br />waktu ada jangkitan HSV. Pada waktu itu, viral load HIV-nya (lihat <a href='http://spiritia.or.id/li/bacali.php?lino=125'>LI 125</a>) biasanya lebih tinggi, dan hal ini dapat meningkatkan kemungkinan HIV ditularkan pada orang lain.</p><br /><p class='SubHead'><b>Bagaimana HSV Menular?</b></p><br /><p>Infeksi HSV ditularkan dari orang ke orang melalui hubungan langsung dengan daerah tubuh yang terinfeksi. <b>Penularan dapat terjadi walaupun tidak ada luka HSV yang terbuka.</b></p><br /><p>Lagi pula, sebagian besar orang dengan HSV tidak mengetahui dirinya<br />terinfeksi dan tidak sadar dapat menyebarkannya. Justru, di AS hanya 9%<br />orang dengan HSV-2 mengetahui dirinya terinfeksi.</p><br /><p class='SubHead'><b>Bagaimana Herpes Diobati?</b></p><br /><p>Perawatan setempat untuk herpes zoster sebaiknya termasuk<br />membersihkan lukanya dengan air garam dan menjaganya tetap kering.<br />Gentian violet dapat dioleskan pada luka.</p><br /><p>Pengobatan baku untuk HSV adalah asiklovir dalam bentuk pil sampai<br />lima kali sehari. Ada versi asiklovir lain dengan nama valasiklovir.<br />Valasiklovir dapat diminum dua kali sehari, tetapi harganya jauh lebih<br />mahal dibandingkan asiklovir. Famsiklovir adalah obat lain yang dipakai<br />untuk mengobati HSV. Obat baru sedang di uji coba. Uji coba fase II<br />terhadap ME609 dari Medivir untuk herpes mulut hampir selesai. PCL016<br />dari Novactyl untuk herpes <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Berkaitan dengan mulut. Untuk pengobatan berarti diberikan melalui mulut, dalam bentuk pil atau cairan')' class='tip'>oral</span> dan kelamin sedang dalam uji coba fase II.</p><br /><p>Obat ini tidak menyembuhkan infeksi HSV. Namun obat ini dapat<br />mengurangi lama dan beratnya jangkitan yang terjadi. Dokter mungkin<br />meresepkan terapi “rumatan” – terapi antiherpes harian – untuk orang<br />dengan HIV yang mengalami HSV kambuhan. Terapi ini dapat mencegah<br />sebagian besar jangkitan kambuh.</p><br /><p>Penyakit herpes dapat menyebabkan rasa nyeri (sakit) yang amat<br />sangat. Rasa sakit ini harus ditangani dengan baik, dengan memakai <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Obat mengatasi nyeri')' class='tip'>analgesik</span> yang cukup untuk menawarkannya.</p><br /><p class='SubHead'><b>Apakah Herpes Dapat Dicegah?</b></p><br /><p>Penyebaran HSV sulit dicegah. Hal ini sebagian karena banyak orang<br />dengan HSV tidak tahu dirinya terinfeksi dan dapat menularkannya. Orang<br />yang tahu dirinya terinfeksi HSV pun mungkin tidak mengetahui mereka<br />dapat menularkan infeksi walaupun mereka tidak mempunyai luka herpes<br />yang terbuka.</p><br /><p>Angka penularan HSV dapat dikurangi dengan penggunaan kondom. Namun<br />kondom tidak dapat mencegah semua penularan. Infeksi HSV dapat menulari<br />dan ditulari dari daerah kelamin yang agak luas – lebih luas daripada<br />yang ditutup oleh celana dalam – dan juga di daerah mulut. Bila orang<br />dengan herpes minum asiklovir setiap hari, mereka dapat mengurangi<br />risiko menulari herpes pada orang lain.</p><br /><p>Para peneliti sekarang mencari <span onmouseout='hideddrivetip()' onmouseover='ddrivetip('Virus atau bakteri yang sudah dilemahkan, yang disuntikkan ke dalam tubuh agar kebal terhadap virus atau bakteri yang sesungguhnya')' class='tip'>vaksin</span><br />untuk mencegah HSV. Satu calon vaksin menujukkan hasil yang baik<br />terhadap HSV-2 pada perempuan, tetapi tidak pada laki-laki. Belum ada<br />vaksin yang disetujui untuk mencegah infeksi HSV, tetapi penelitian<br />terhadap vaksin untuk HSV berlanjut terus.</p><br /><p class='SubHead'><b>Garis Dasar</b></p><br /><p>Herpes simpleks adalah infeksi virus yang dapat menyebabkan herpes<br />kelamin atau “luka demam” di sekitar mulut. Sebagian besar orang yang<br />terinfeksi HSV tidak mengetahui dirinya terinfeksi. HSV mudah menular<br />dari orang ke orang waktu hubungan seks atau hubungan langsung yang<br />lain dengan daerah infeksi HSV. Herpes dapat menular walaupun luka<br />terbuka tidak terlihat.</p><br /><p>Belum ada obat penyembuhan untuk herpes. Sekali kita terinfeksi,<br />kita tetap terinfeksi, secara terus-menerus. Orang dengan herpes dapat<br />sekali-kali mengalami jangkitan kulit melepuh yang sakit. Setelah<br />setiap jangkitan selesai, infeksi sementara menjadi laten atau tidak<br />aktif. Orang dengan HIV mengalami jangkitan HSV yang lebih sering dan<br />lebih parah.</p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-73859589671428536882008-09-09T07:18:00.001+07:002008-09-09T08:21:54.920+07:00Herpes Zoster<div xmlns="http://www.w3.org/1999/xhtml"><p class="SubHead"><u><b>Apa <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Radang kulit akibat beberapa virus berbeda')" class="tip">Herpes</span> Zoster Itu?</b></u></p><span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Penyakit kulit akibat virus varisela zoster')" class="tip">Herpes zoster</span> (<i>Shingles</i>) adalah suatu penyakit yang membuat sangat nyeri (rasa sakit yang amat sangat). Penyakit ini juga disebabkan oleh <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Kuman yang tidak dapat dilhat dengan mikroskop biasa, yang bereplikasi dalam sel yang diinfeksikannya')" class="tip">virus</span><br /><p>herpes yang juga mengakibatkan cacar air (virus varisela zoster).<br />Seperti virus herpes yang lain, virus varisela zoster mempunyai tahapan<br />penularan awal (cacar air) yang diikuti oleh suatu tahapan tidak aktif.<br />Kemudian, tanpa alasan virus ini jadi aktif kembali, menjadikan<br />penyakit yang disebut sebagai herpes zoster.</p>Kurang lebih 20% orang yang pernah cacar air lambat laun akan<br /><p>mengembangkan herpes zoster. Keaktifan kembali virus ini kemungkinan<br />akan terjadi pada orang dengan sistem kekebalan yang lemah. Ini<br />termasuk orang dengan penyakit HIV, dan orang di atas usia 50 tahun.</p>Herpes zoster hidup dalam <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Satu kumpulan sel yang sejenis yang bertindak bersama-sama untuk mengerjakan fungsi tertentu. Ada empat jaringan dasar di dalam tubuh, yakni epitelium, sendi penyambung, otot dan saraf')" class="tip">jaringan</span><br /><p>saraf. Kejangkitan herpes zoster dimulai dengan gatal, mati rasa,<br />kesemutan atau rasa nyeri yang parah pada daerah bentuk tali lebar di<br />dada, punggung, atau hidung dan mata. Walaupun jarang, herpes zoster<br />dapat menular pada saraf wajah dan mata. Ini dapat menyebabkan<br />jangkitan di sekitar mulut, pada wajah, leher dan kulit kepala, dalam<br />dan sekitar telinga, atau pada ujung hidung.</p>Jangkitan herpes zoster hampir selalu terjadi hanya pada satu sisi tubuh. Setelah beberapa hari, <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Gatal-gatalan pada kulit')" class="tip">ruam</span><br /><p>muncul pada daerah kulit yang berhubungan dengan saraf yang meradang.<br />Lepuh kecil terbentuk, dan berisi cairan. Kemudian lepuh pecah dan<br />berkeropang.</p>Jika lepuh digaruk, infeksi kulit dapat terjadi. Ini membutuhkan pengobatan dengan <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Obat mematikan bakteri')" class="tip">antibiotik</span><p> dan mungkin menimbulkan bekas.</p>Biasanya, ruam hilang dalam beberapa minggu, tetapi kadang-kadang<br /><p>rasa nyeri yang parah dapat bertahan berbulan-bulan bahkan<br />bertahun-tahun. Kondisi ini disebut “<span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Rasa sakit pada saraf')" class="tip">neuralgia</span> pascaherpes”.</p><br /><p class="SubHead"><u><b>Herpes Zoster dan HIV</b></u></p>Herpes zoster bukan infeksi yang menyebutkan kita AIDS.<br /><p>Penelitian baru terhadap <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Orang yang hidup dengan HIV/AIDS')" class="tip">Odha</span> menemukan bahwa angka herpes zoster tertinggi terjadi pada:</p><ul><li>laki-laki gay dan biseks</li></ul><ul><li>orang di bawah usia 29 tahun</li></ul><ul><li>orang dengan jumlah CD4 di bawah 500</li></ul><ul><li>orang kulit putih</li></ul>Herpes zoster dapat terjadi pada orang dengan HIV baru setelah mereka mulai memakai terapi <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Obat yang digunakan untuk mengobati retrovirus seperti HIV, untuk menghambat perkembangbiakannya')" class="tip">antiretroviral</span> (ART). Kasus herpes zoster ini kemungkinan diakibatkan pemulihan pada <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Sistem dalam tubuh yang seharus melindungi kita terhadap infeksi')" class="tip">sistem kekebalan tubuh</span> (lihat <a href="http://spiritia.or.id/li/bacali.php?lino=483">Lembaran Informasi 483</a>).<br /><br /><p class="SubHead"><u><b>Bagaimana Herpes Zoster Menular?</b></u></p>Herpes zoster hanya dapat terjadi setelah kita mengalami cacar air.<br /><p>Jika orang yang sudah menderita cacar air berhubungan dengan cairan<br />dari lepuh herpes zoster, kita tidak dapat ‘tertular’ herpes zoster.<br />Namun, kita yang belum menderita cacar air dapat terinfeksi herpes<br />zoster dan mengembangkan cacar air. Jadi kita yang belum terinfeksi<br />harus menghindari hubungan dengan ruam herpes zoster atau dengan bahan<br />yang mungkin sudah menyentuh ruam atau lepuh herpes zoster.</p><br /><u><b>Bagaimana Herpes Zoster Diobati?</b></u><br /><p>Perawatan setempat untuk herpes zoster sebaiknya termasuk<br />membersihkan lukanya dengan air garam dan menjaganya tetap kering.<br />Gentian violet dapat dioleskan pada luka.</p>Beberapa jenis obat dipakai untuk mengobati herpes zoster. Obat ini<br /><p>termasuk obat antiherpes, dan beberapa jenis obat penawar nyeri.</p><b>Obat anti-herpes:</b> Pengobatan baku untuk herpes zoster adalah dengan asiklovir, yang dapat diberikan dalam bentuk pil atau secara <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Penyuntikan atau infus langsung ke aliran darah melalui pembuluh darah agar obat cepat memberikan reaksi')" class="tip">intravena</span> (infus) untuk kasus yang lebih berat.<br /><p>Baru-baru ini, dua obat baru telah disetujui untuk pengobatan herpes<br />zoster: famsiklovir dan valasiklovir yang diminum tiga kali sehari,<br />dibanding dengan asiklovir yang diminum lima kali sehari. Semua obat<br />ini paling berhasil apabila dimulai dalam tiga hari pertama setelah<br />rasa nyeri herpes zoster mulai terasa.</p><br /><p><b>Menghambat saraf (<i>nerve blockers</i>):</b> Dokter sering<br />meresepkan berbagai obat penawar nyeri untuk orang dengan herpes<br />zoster. Karena rasa nyeri herpes zoster dapat begitu hebat, peneliti<br />mencari cara untuk menghambat rasa nyeri tersebut. Suntikan obat bius<br />dan/atau <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Obat yang dipakai untuk mengurangi tanggapan kekebalan')" class="tip">steroid</span> sedang diteliti sebagai menghambat saraf. Obat tersebut dapat disuntik pada saraf perifer atau pada <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Jaringan lembut yang terletak pada rongga tulang pipa, terutama tulang belakang, tempat sel darah dibentuk')" class="tip">sumsum tulang</span> belakang (susunan saraf pusat).</p><br /><b>Pengobatan kulit: </b>Beberapa jenis krim, jel dan semprotan sedang diteliti. Obat ini memberi keringanan sementara pada rasa sakit. <i>Capsaicin</i>,<br /><p>senyawa kimia yang membuat cabe pedas, tampaknya berhasil baik.<br />Tambahannya, pada 1999, obat bius lidokain dalam bentuk tempelan<br />disetujui di AS. Tempelan ini, dengan nama merek Lidoderm, meringankan<br />rasa nyeri pada beberapa orang dengan herpes zoster. Karena dioleskan<br />pada kulit, risiko <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Daya kerja atau efek obat (atau vaksin) yang tidak diharapkan. Istilah ini biasanya berhubungan dengan dampak buruk seperti sakit kepala, ruam, atau kerusakan hati')" class="tip">efek samping</span> obat ini lebih rendah dibanding dengan obat penawar nyeri dengan bentuk pil.</p><br /><p><b>Obat penawar nyeri lain:</b> Beberapa obat yang biasanya dipakai<br />untuk mengobati depresi, epilepsi dan rasa sakit yang berat kadang kala<br />dipakai untuk nyeri herpes zoster. Obat tersebut dapat menimbulkan<br />berbagai efek samping. Nortriptilin adalah obat antidepresi yang paling<br />umum dipakai untuk nyeri herpes zoster. Pregabalin adalah obat<br />antielepsi yang juga dipakai untuk rasa nyeri setelah herpes zoster.</p><br /><p class="SubHead"><u><b>Dapatkah Herpes Zoster Dicegah?</b></u></p>Saat ini, belum ada cara untuk meramalkan jangkitan herpes zoster.<br /><p>Ada penelitian yang menunjukkan bahwa dengan vaksinasi orang yang<br />lebih tua dengan vaksin cacar air yang lebih kuat daripada yang biasa<br />dipakai untuk anak dapat meningkatkan jenis kekebalan yang dianggap<br />perlu untuk melawan virus. Para peneliti berharap peningkatan kekebalan<br />ini akan mengurangi risiko herpes zoster pada kehidupan selanjutnya.</p>Zostavaks, sebuah <span onmouseout="hideddrivetip()" onmouseover="ddrivetip('Virus atau bakteri yang sudah dilemahkan, yang disuntikkan ke dalam tubuh agar kebal terhadap virus atau bakteri yang sesungguhnya')" class="tip">vaksin</span> terhadap herpes zoster, sudah disetujui di AS. Namun vaksin ini belum diuji coba pada orang dengan sistem kekebalan yang lemah, termasuk Odha.<br /><p class="SubHead"><u><b><br /></b></u></p><p class="SubHead"><u><b>Garis Dasar</b></u></p>Herpes zoster adalah penyakit yang tidak dapat diramalkan dan<br /><p>membuat sangat nyeri. Penyakit ini disebabkan virus yang menjadi aktif<br />kembali setelah pernah mengakibatkan cacar air. Walaupun tidak secara<br />langsung dikaitkan dengan HIV, herpes zoster tampaknya lebih sering<br />terjadi pada Odha.</p>Walaupun herpes zoster dapat hilang dalam beberapa minggu, rasa nyeri yang berat dapat berlanjut selama beberapa bulan.<br /><p>Vaksin terhadap herpes zoster telah disetujui di AS, tetapai vaksin ini belum diuji coba pada Odha.</p>Penyakit ini diobati dengan asiklovir, diminum lima kali sehari,<br /><p>atau pada kasus yang berat diberikan lewat infus. Dua obat yang lebih<br />baru, famsiklovir dan valasiklovir, kelihatan lebih efektif terhadap<br />rasa nyeri yang timbul akibat herpes zoster, dan hanya perlu diminum<br />tiga kali sehari.</p>Bisa jadi sangat sulit menahan rasa nyeri akibat herpes zoster.<br /><p>Suatu pengobatan baru adalah tempelan obat bius yang dapat ditempelkan<br />langsung pada kulit.</p></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-8209353169859374935.post-81948234650613668762008-09-08T08:03:00.001+07:002008-09-08T08:11:40.471+07:00Install Ubuntu Hardy Heron (8.04.1) on the Acer Aspire One<div class="entry"> <div class="snap_preview"> <h3>Fully functional:</h3> <ul><li>Suspend / Resume </li><li>Video (with desktop effects) </li><li>Wireless Networking </li><li>Wired Networking </li><li>Webcam </li><li>USB </li><li>Silent Fan </li></ul> <p class="line867"> </p><h3>Partial Function:</h3> <ul><li>Card Readers (only work if card in when booting) </li><li>Audio - there is sound, issues detailed below </li></ul> <p class="line867"> </p><h3>Not Functional:</h3> <ul><li>Hibernate on A110L </li><li>Card Reader power saving </li><li>wifi power saving </li><li>wifi kill switch </li></ul> <p class="line867"> </p><h2>Prerequisites:</h2> <p class="line874">Before you begin you will need the following:</p> <ul><li> <p class="line862">A copy of 8.04.1 Hardy Heron.<br />This is the latest version. If you downloaded the ISO a while ago, it may be 8.04.0. The original 8.04.0 release will not even boot. </p> </li><li>An external USB CD-ROM. If not: <ul><li>A 1+ GB memory key that can be formatted. </li><li> <p class="line862">A copy of the liveUSB DEB. Website: <a class="http" href="http://klik.atekon.de/liveusb">http://klik.atekon.de/liveusb</a> and the DEB: <a class="http" href="http://ppa.launchpad.net/probono/ubuntu/pool/main/l/liveusb/">http://ppa.launchpad.net/probono/ubuntu/pool/main/l/liveusb/</a>.</p> </li><li>A wired network connection. </li><li>Another computer, with network access. </li></ul></li></ul> <p class="line867"> </p><h2>Note on using this guide</h2> <p class="line874">This guide was written with Ubuntu in mind. Generally everything works the same with the other variants of the distribution (Kubuntu, Xubuntu). For ease of use gedit is the text editor we’ll be using. If you are using a variant please substitute a different text editor (kate for Kubuntu, mousepad for Xubuntu or just use vim/emacs/nano).</p> <p class="line867"> </p><h2>Step One: Preparation</h2> <p class="line867"><em>(Skip this step if you have an external USB CD-ROM)</em></p> <p class="line874">If we don’t have any external USB CD-ROM the first thing we need to do is create a bootable copy of the Ubuntu LiveCD on a memory key. This will be our install media for the Aspire One. Its actually pretty similar to creating recovery media for Linpus Lite (the included version of Linux).</p> <p class="line874">Download and copy the LiveUSB .deb file from the link above to a memory key (you can use the same one we we are going to format to create the install media, we only need this file once), and remove the memory key. The LiveUSB software should only be installed when booted off the LiveCD environment, so we do that next.</p> <p class="line862">Boot to the 8.04.1 Live CD on your other computer, and choose the first option off the boot menu (Try Ubuntu). When you reach the desktop insert the memory key with the LiveUSB software one it and double click. Follow the prompts to install it. Now we can create our bootable USB key. Start the LiveUSB application from System -> Administration -> Install LiveUSB. Select the target device (my two keys were listed by a human readable name, so it was easy to find) and click Execute. It will give you a warning about data loss, so double check that you selected the correct device and continue.</p> <p class="line874">Once that is done, you can shut down the other computer and remove the memory key.</p> <p class="line867"> </p><h2>Step Two: Install Ubuntu</h2> <p class="line874">Shut down your Aspire One and insert the external USB CD-ROM or the memory key that we just used. Turn it on and tap F12 to bring up the boot menu.</p> <p class="line862">With a CD-ROM, choose the USB CD-ROM option. With the bootable memory key created, choose the USB HDD option. This will boot you to the USB CD-ROM/LiveUSB stick, and allow you to install Ubuntu. Install it like normal if you have the hard disk Aspire One. If you have the SDD Aspire One, for good performance and to increase the life of the SSD use a non-journaled filesystem (suggestion: EXT2). If you have already installed with EXT3 then follow this post: <a class="http" href="http://www.aspireoneuser.com/forum/viewtopic.php?f=5&t=164&st=0&sk=t&sd=a&start=10#p1177">http://www.aspireoneuser.com/forum/viewtopic.php?f=5&t=164&st=0&sk=t&sd=a&start=10#p1177</a> to convert to EXT2. Installation (file copy) will take a LONG time (hour +). If your not currently connected to the internet on a wired connection, you may get an error about setting up a mirror. Don’t worry about it if you do however, its non-fatal.</p> <p class="line867"> </p><h2>Step 3: Tweak / Fix</h2> <p class="line862">So now we should have an installed Ubuntu system. At this point wire your One into the network. If you use DHCP it should pick up an IP address automatically. The first thing you will want to do is updates, since the wireless driver needs to be reinstalled after every kernel update. Open a terminal (Applications -> Accessories -> Terminal). Do the updates:</p> <pre>sudo apt-get update<br />sudo apt-get upgrade</pre> <p class="line867"> </p><h3>WIRELESS:</h3> <p class="line862">Now we need to disable the hardware drivers that Ubuntu tries to use before the ones we make will function. So go to System -> Administration -> Hardware Drivers and uncheck everything. It should prompt us to reboot, so lets do it now.</p> <p class="line874">We need to grab the wireless driver, and the things we need to build it, from a terminal:</p> <pre>mkdir source<br />cd source<br />wget http://snapshots.madwifi.org/madwifi-hal-0.10.5.6/madwifi-hal-0.10.5.6-r3835-20080801.tar.gz<br />tar -xzvf madwifi-hal-0.10.5.6-r3835-20080801.tar.gz<br />cd madwifi-hal-0.10.5.6-r3835-20080801<br />sudo apt-get install build-essential linux-headers-$(uname -r)</pre> <p class="line874">And we build and install:</p> <pre>make<br />sudo make install<br />sudo modprobe ath_pci</pre> <p class="line874">In order to have the wireless work after reboot, add the following line to /etc/modules (”sudo gedit /etc/modules”) to automatically load the module when booting:</p><pre>ath_pci</pre> <p class="line862">You should now have working wireless. However you may want to do the following to prevent problems <em>(the symbol mismatch)</em> when the module is loaded:</p> <p class="line862">Add <strong>ath_hal</strong> to the <strong>DISABLED_MODULES=</strong> stanza in <strong>/etc/default/linux-restricted-modules-common</strong></p> <p class="line867"><em>(i.e. ‘DISABLED_MODULES=”ath_hal”‘)</em></p> <p class="line874">Every time there is a kernel update you will need to perform the following steps to make the wireless work. Go to the directory (madwifi-hal-0.10.5.6-r3835-20080801) and run:</p> <pre>make clean<br />make<br />sudo make install</pre> <p class="line867"> </p><h3>WIRELESS LED:</h3> <p class="line862">To get your awesome wireless led to blink for you based on traffic, put these lines in /etc/rc.local, just above the string <em>exit 0</em> (below doesn’t work).</p> <pre>sysctl -w dev.wifi0.ledpin=3<br />sysctl -w dev.wifi0.softled=1</pre> <p class="line874">The led on the front will now do the association blink, as well as blink based on wireless traffic.</p> <p class="line874">The wifi kill switch uses these keycodes (also to use in rc.local):</p><pre>/usr/bin/setkeycodes e055 159<br />/usr/bin/setkeycodes e056 158</pre> <p class="line867"> </p><h3>CARD READER:</h3> <p class="line862">According to <a class="http" href="http://wiki.debian.org/DebianAcerOne">DebianAcerOne</a> the following command enables the card reader:</p><pre>setpci -d 197b:2381 AE=47</pre> <p class="line874">The card reader works fine if cards are inserted before booting.</p> <ul><li>it might help to suspend/resume </li><li>a static entry for the device /dev/mmcblk01p in /etc/fstab might help </li><li>powersaving can be done with the jmb38x_d3e.sh script </li></ul> <p class="line867"> </p><h3>USB MOUNT:</h3> <p class="line867"><em>(Do this step <strong>only</strong> if you get an error inserting a USB stick)</em></p> <p class="line874">If you insert a memory key, you may notice an error and that it cannot be mounted. This is due to the CD-ROM entry in the fstab. Since we don’t have an optical drive on the One we will comment that out. From a terminal again:</p> <pre>sudo gedit /etc/fstab</pre> <p class="line874">You should see a line that looks like:</p> <pre>/dev/sdb /media/cdrom0 udf,iso9660 user,noauto,exec 0 0</pre> <p class="line874">add a hash in front:</p> <pre>#/dev/sdb /media/cdrom0 udf,iso9660 user,noauto,exec 0 0</pre> <p class="line874">Reboot, and automount should work.</p> <p class="line867"> </p><h3>NOISE (FAN CONTROL)</h3> <p class="line874">Bios v0.3114 doesn’t manage correctly Fan speed, resulting in a very noisy AA0. Solution:</p> <ul><li> <p class="line862">Download the <a class="http" href="http://code.google.com/p/aceracpi/wiki/EmbeddedController">acer_ec.pl</a> script (<a class="http" href="http://electronpusher.org/%7Erachel/acerfand">Direct download</a>).</p> </li><li class="gap"> <p class="line862">Download the <a class="http" href="http://electronpusher.org/%7Erachel/acerfand">acerfand</a> daemon script (<a class="http" href="http://aceracpi.googlecode.com/svn/trunk/acer_ec/acer_ec.pl">Direct download</a>).</p> </li><li class="gap">Execute these lines in a terminal in the directory you downloaded the above scripts: </li></ul> <pre> chmod a+x acerfand<br />sudo cp acer_ec.pl acerfand /usr/local/bin/</pre> <ul><li>To run it straight away: </li></ul> <pre> sudo acerfand</pre> <ul><li>To run it at boot: </li></ul> <pre> sudo gedit /etc/rc.local</pre> <p class="line862">Insert the following line above the <em>exit 0</em> at the bottom:</p> <pre> /usr/local/bin/acerfand</pre> <p class="line874">The fan is not completely disabled. When the default temperature is reached (60ºC), fan works again. According to Intel, the Atom chip could work until 99ºC.</p> <p class="line867"><strong>Optional:</strong> Above instructions will work fine, but if you want to define another temperature:</p> <ul><li>Create an /etc/acerfand.conf file. The file is just a shell script that sets up to three values. eg: </li></ul> <pre>INTERVAL=5<br />FANOFF=60<br />FANAUTO=70</pre> <p class="line874">Those are the default values, if the /etc/acerfand.conf file isn’t found.</p> <p class="line874">INTERVAL is the polling interval in seconds</p> <p class="line874">FANOFF is the temperature (in Celsius Degrees) at or below which to turn the fan off, if it’s currently on auto</p> <p class="line874">FANAUTO is the temperature (in Celsius Degrees) at or above which to turn the fan to auto, if it’s currently off</p> <p class="line867"><a class="http" href="http://wiki.aspireone.net/index.php/How_to_hack_the_noisy_fan">More information</a> from the original source, AspireOne Wiki.</p> <p class="line867"> </p><h3>OPTIMIZING SSD PERFORMANCE:</h3> <p class="line867"><em>(Skip this step if you have the hard disk Acer Aspire One)</em></p> <p class="line862">The performance of the SSD drive can be significantly improved by a few tweaks described in <a class="http" href="http://blogs.zdnet.com/perlow/?p=9190">an article by Jason Perlow</a> (Tweek #1 is not working with Ubuntu on the Aspire One). The most important of these are described here.</p> <p class="line867"> </p><h4>Change the file system mount options on SSDs to “noatime”</h4> <p class="line874">Edit /etc/fstab (sudo gedit /etc/fstab) and change the the option “relatime” to “noatime”. The line for the root partition should then be something like:</p><pre>UUID=f0ae2c59-83d2-42e7-81c4-2e870b6b255d / ext2 noatime,errors=remount-ro 0 1</pre> <p class="line867"> </p><h4>Use the “noop” I/O scheduler</h4> <p class="line874">Edit /boot/grub/menu.lst using your favorite editor, and add “elevator=noop” as an option. The default kernel configuration, found in the last part of the file should be something like:</p><pre>title Ubuntu 8.04.1, kernel 2.6.24-19-generic<br />root (hd0,0)<br />kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=f0ae2c59-83d2-42e7-81c4-2e870b6b255d ro quiet splash elevator=noop<br />initrd /boot/initrd.img-2.6.24-19-generic<br />quiet</pre> <p class="line874">In order for the changes to remain when updating the kernel, also in menu.lst, find the line</p><pre># defoptions=quiet splash</pre> <p class="line874">and add “elevator=noop” as an option:</p><pre># defoptions=elevator=noop quiet splash</pre> <p class="line867"> </p><h3>REDUCING SSD WEAR:</h3> <p class="line867"><em>(Skip this step if you have the hard disk Acer Aspire One)</em></p> <p class="line874">Frequent writes to the SSD will cause failure eventually. We can reduce the number of writes to the SSD my moving our logs to a temporary filesystem in RAM that gets destroyed at ever reboot. Now this means your logs will not be persistent across reboots making debugging difficult in some cases. This step is optional of course, so if you need the logs for an extended period of time do not follow these steps.</p> <p class="line874">Open your fstab again, and add the following lines:</p> <pre>sudo gedit /etc/fstab<br />tmpfs /var/log/apt tmpfs defaults 0 0<br />tmpfs /var/log tmpfs defaults 0 0<br />tmpfs /tmp tmpfs defaults 0 0<br />tmpfs /var/tmp tmpfs defaults 0 0</pre> <p class="line867"> </p><h3>AUDIO:</h3> <p class="line874">Out of the box there are various issues with the sound. These range from headphone detection not functioning correctly, to the internal MIC not working. There are solutions to these problems. Currently, however, there is no known way to get everything working at once. All of the steps begin the same way, rebuilding ALSA:</p> <pre>sudo apt-get install module-assistant<br />sudo m-a update<br />sudo m-a prepare<br />sudo m-a a-i alsa<br />sudo alsa force-unload<br />sudo depmod -ae<br />sudo modprobe snd-hda-intel</pre> <p class="line874">Add the following line to the end of /etc/modules in order to ensure that the module is loaded during bootup:</p><pre>snd-hda-intel</pre> <p class="line874">Now we need to make a choice. To have the internal MIC non-functional (external works), but sound working after suspend and resume, we edit /etc/modprobe.d/alsa-base (sudo gedit /etc/modprobe.d/alsa-base) and add the following line to the bottom:</p> <pre>options snd-hda-intel model=toshiba</pre> <p class="line874">Reboot for that to take effect.</p> <p class="line874">To have the internal MIC function correctly, but no sound after suspending and resuming the computer add or change the following to the /etc/modprobe.d/alsa-base as before:</p> <pre>options snd-hda-intel model=auto</pre> <p class="line874">Again, reboot for this to take effect.</p> <p class="line874">For some unknown reason some people don’t hear any sound with either option. If you experience this problem you might want to use the option in /etc/modprobe.d/alsa-base as before to the following to resolve this problem:</p> <pre>options snd-hda-intel model=acer</pre> <p class="line874">If you experience crackling sound after rebooting, insert the following line in /etc/modprobe.d/blacklist:</p> <pre>blacklist snd_pcsp</pre> <p class="line867"><strong>Optional:</strong> The default sound level is low. Open a terminal and type <em>alsamixer</em> to adjust volume.</p> <p class="line867"> </p><h3>TWEAKS TO MAKE BETTER USE OF THE ASPIRE ONE’S SMALL SCREEN:</h3> <p class="line874">There are various methods that will help you make better use of the Aspire One’s small screen. One of the most important is being able to move windows that are too large to fit on the screen at once. To move a hidden part of the window into view, click and drag with the left mouse button on any part of the window while holding down the ALT key. However, you won’t be able to drag windows so the top of the window is above the top of the screen. To fix that, enter the following in a terminal window:</p> <p class="line867"><tt>gconftool-2 –set /apps/compiz/plugins/move/allscreens/options/constrain_y –type bool 0</tt></p> <p class="line874">Since the Aspire One’s screen has almost twice as much resolution horizontally as vertically, having panels on both the top and bottom is not ideal. You may want to remove the top or bottom panels, make them smaller, or move them so that they are vertical, on the left and right side, instead of horizontal on top and bottom.</p> <p class="line867"> </p><h3>HIBERNATE:</h3> <p class="line862">In some set-ups, using hibernate has been reported to cause <a class="http" href="http://www.aspireoneuser.com/forum/viewtopic.php?f=28&t=511">file corruption</a>.</p> <p class="line867"> </p><h3>TWEAKS FOR POWERSAVING (Optional):</h3> <p class="line874">Add the following to the /etc/rc.local file:</p> <pre># Economize the SSD<br />sysctl -w vm.swappiness=1 # Strongly discourage swapping<br />sysctl -w vm.vfs_cache_pressure=50 # Don't shrink the inode cache aggressively<br /><br /># As in the rc.last.ctrl of Linpus<br />echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor<br />echo ondemand > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor<br />cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate_max > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate<br /><br />echo 3000 > /proc/sys/vm/dirty_writeback_centisecs<br />echo 20 > /proc/sys/vm/dirty_ratio<br />echo 10 > /proc/sys/vm/dirty_background_ratio<br /><br />echo 1 > /sys/devices/system/cpu/sched_smt_power_savings<br />echo 10 > /sys/module/snd_hda_intel/parameters/power_save<br />echo 5 > /proc/sys/vm/laptop_mode<br /><br />#Decrease power usage of USB while idle<br />[ -L /sys/bus/usb/devices/1-5/power/level ] && echo auto > /sys/bus/usb/devices/1-5/power/level<br />[ -L /sys/bus/usb/devices/5-5/power/level ] && echo auto > /sys/bus/usb/devices/5-5/power/level</pre> <p class="line867"> </p><h3>NETBOOK REMIX (Optional):</h3> <p class="line862">To install <a class="https" href="https://launchpad.net/netbook-remix">Ubuntu Netbook remix</a> -</p> <ul><li>Insert the following into /etc/apt/sources.list: </li></ul> <pre>deb http://ppa.launchpad.net/netbook-remix-team/ubuntu hardy main<br />deb-src http://ppa.launchpad.net/netbook-remix-team/ubuntu hardy main</pre> <ul><li>then execute </li></ul> <pre>sudo apt-get update<br />sudo apt-get install go-home-applet human-netbook-theme maximus ume-launcher window-picker-applet</pre> <ul><li> <p class="line862">Add maximus as startup program (system > preferences > sessions > startup programs)</p> </li><li> <p class="line862">Change the desktop theme to Human-Netbook (system > preferences > appearance > theme)</p> </li><li>Delete the bottom panel </li><li>Reconfigure the top panel to contain the following items - <ul><li>Go Home Applet </li><li>Window Picker Applet </li><li>Notification Area </li><li>Mixer Applet </li><li>Clock </li></ul> </li><li>There is a bug in the ume-launcher after resuming from suspend. To work around this place the following in /etc/pm/sleep.d/01UMELauncher - </li></ul> <pre>#<br /># Copyright 2008 Matteo Collina <matteo.collina@gmail.com><br />#<br /># This program is free software; you can redistribute it and/or modify<br /># it under the terms of version 2 of the GNU General Public License as<br /># published by the Free Software Foundation.<br /><br />export DISPLAY=:0.0<br /><br />TMPFILE=/tmp/.launcher/resume-event<br /><br />case "$1" in<br /> suspend|hibernate)<br /> rm -rf $TMPFILE<br /> echo "Removed resume-notify file"<br /> ;;<br /> resume|thaw)<br /> touch $TMPFILE<br /> echo "Created resume-notify file"<br /> ;;<br />esac<br /><br />exit $?</pre> <ul><li>Make the above file executable - </li></ul> <pre>sudo chmod +x /etc/pm/sleep.d/01UMELauncher</pre> <p class="line867"> </p><h3>Flash 9.0.48 (Optional, recommended for 512M of RAM):</h3> <p class="line862">Ubuntu Hardy installs flash version 9.0.115, this version needs a lot of memory to work and makes ‘AspireOne’ slower than it is. A good option is to come back to the last fast official version of flash (9.0.48). Just download ‘Flash player 9 (99MB)’ file from:</p> <p class="line867"><a class="http" href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266&sliceId=2">http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266&sliceId=2</a></p> <p class="line874">In this file there are a lot of old flash versions, navigate to 9r48 and uncompress this folder. Double click ‘flash-player installer’, choose ‘Run in terminal’ and follow the instructions.</p></div> </div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-32703156551087675952008-09-06T00:26:00.001+07:002008-12-11T07:17:22.140+07:00Installing Windows XP on the Asus EEE pc using a single USB flash drive.<div xmlns='http://www.w3.org/1999/xhtml'><span style='font-size: 130%;'><span style='font-weight: bold;'>Please note this tutorial works on all computers not just the Asus EEE PC.</span></span><br/><span name='intelliTxt' id='intelliTxt'>To complete this tutorial you need a 32bit version of Windows XP or Windows Vista installed on your home PC.</span><br/><br/><span name='intelliTxt' id='intelliTxt'>What you'll need:</span><br/><span name='intelliTxt' id='intelliTxt'><a href='http://files-upload.com/files/665634/usb_prep8.zip'>USB_PREP8</a> (<a href='http://www.2shared.com/file/2581432/a65c092a/usb_prep8.html'>alternative download</a>)<br/><a href='http://www.2shared.com/file/2581436/a131cd33/PeToUSB_3007.html'>PeToUSB</a> (<a href='http://files-upload.com/files/665642/PeToUSB_3.0.0.7.zip'>alternative download</a>)</span><br/><a href='http://www.2shared.com/file/2585881/5ad9ef68/bootsect.html'>Bootsect.exe</a> (<a href='http://files-upload.com/files/668562/bootsect.zip'>alternative download</a>)<br/><span style='font-weight: bold;'>Special<br />Note: If you use the program Nlite be sure to keep the manual<br />installation files as the USB_prep8 script relies on these files.</span><br/><br/>Extract the files in Bootsect.zip<br/>The next step is to extract USB_prep8 and PeToUSB.<br/>Next copy the PeToUSB executable into the USB_prep8 folder.<br/>Inside of the USB_prep8 folder double click the executable named usb_prep8.cmd.<br/><br/>The window that opens will look like this:<br/><br/><a href='http://3.bp.blogspot.com/_tzQM6SAdnNo/R5gZam3uf-I/AAAAAAAAAOw/xr8JMnO5K8Y/s1600-h/usbprep1.JPG' onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}'><img border='0' id='BLOGGER_PHOTO_ID_5158901318054477794' alt='' src='http://3.bp.blogspot.com/_tzQM6SAdnNo/R5gZam3uf-I/AAAAAAAAAOw/xr8JMnO5K8Y/s320/usbprep1.JPG' style='margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;'/></a><br/><br/>Press any key to continue<br/><br/>You next window will look like this:<a href='http://3.bp.blogspot.com/_tzQM6SAdnNo/R5gaBm3ugAI/AAAAAAAAAPA/oQBoKdL6jDs/s1600-h/petousb.JPG' onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}'><img border='0' id='BLOGGER_PHOTO_ID_5158901988069376002' alt='' src='http://3.bp.blogspot.com/_tzQM6SAdnNo/R5gaBm3ugAI/AAAAAAAAAPA/oQBoKdL6jDs/s320/petousb.JPG' style='margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;'/></a><br/>These settings are preconfigured for you all you need to do now is click start.<br/>Once<br />the format is complete DO NOT close the window just leave everything as<br />it is and open a command prompt from your start menu (type cmd in the<br />search bar or run box depending on your version of windows.).<br/><br/>Inside of the command windows go to the directory you have bootsect.exe saved.<br/>(use the cd directoryname command to switch folders)<br/><br/>Now<br />type "bootsect.exe /nt52 R:" NOTE R: is the drive letter for my USB<br />stick if yours is different you need to change it accordingly. What<br />this part does is write the correct boot sector to your USB stick, this<br />allows your PC to boot from the USB stick without it nothing works.<br/>Please<br />note: When running the bootsect.exe command you cannot have any windows<br />open displaying the content of your USB stick, if you have a window<br />open bootsect.exe will be unable to lock the drive and write the<br />bootsector correctly.<br/><br/>If all went well you should see "Bootcode was successfully updated on all targeted volumes."<br/><br/>Now you can close this command prompt (don't close the usbprep8 one by mistake) and the petousb window.<br/><br/>You window you see now should look like this:<br/><a href='http://1.bp.blogspot.com/_tzQM6SAdnNo/R5gXxG3uf8I/AAAAAAAAAOM/OniMnTCtpR4/s1600-h/usbprep2.JPG' onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}'><img border='0' id='BLOGGER_PHOTO_ID_5158899505578278850' alt='' src='http://1.bp.blogspot.com/_tzQM6SAdnNo/R5gXxG3uf8I/AAAAAAAAAOM/OniMnTCtpR4/s320/usbprep2.JPG' style='margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;'/></a><br/>If it doesn't try pressing enter.<br/><br/>Now you need to enter the correct information for numbers 1-3.<br/>Press<br />1 and then enter. A folder browse window will open for you to browse to<br />the location of you XP setup files (aka your cdrom drive with xp cd in)<br/>Press 2 and enter a letter not currently assigned to a drive on your PC<br/>Press 3 and enter the drive letter of your USB stick<br/>Press 4 to start the process.<br/><br/>The<br />script will ask you if its ok to format drive T:. This is just a temp<br />drive the program creates to cache the windows installation files.<br />Press Y then enter.<br/><br/>Once it's done formating press enter to<br />continue again, you can now see the program copying files to the temp<br />drive it created. Once this is done press enter to continue again.<br/><br/>Next you will see a box pop up asking you to copy the files to USB drive yes/no you want to click yes.<br/><br/>Once<br />the script has completed copy files a popup window asking if you would<br />like to USB drive to be preferred boot drive U: select YES on this<br />window.<br/><br/>Now select yes to unmount the virtual drive.<br/><br/>Ok we are done the hard part, close the usbprep8 window.<br/><br/>Now make sure your EEE pc is configured with USB as the primary boot device.<br/>Insert your USB drive and boot up the EEE.<br/><br/>On the startup menu you have two options, select option number 2 for text mode setup.<br/><br/>From<br />this point on it is just like any other windows XP installation<br />delete/recreate the primary partition on your EEE pc and format it<br />using NTFS. Make sure you delete ALL partitions and recreate a single<br />partition or you will get the hal.dll error message.<br/><br/>Once the<br />text mode portion of setup is complete it will boot into the GUI mode<br />(you can press enter after the reboot if your too excited to wait the<br />30 seconds)<br/><br/>Once the GUI portion of setup is complete you will<br />again have to boot into GUI mode this will complete the XP installation<br />and you will end up at you XP desktop. It is very important that you DO<br />NOT REMOVE THE USB STICK before this point. Once you can see your start<br />menu it is safe to remove the usb stick and reboot your pc to make sure<br />everything worked.<br/><br/>This method has advantages over all current<br />no cdrom methods of installing XP to the EEE. You do not have to copy<br />setup files in DOS to the SSD and install from there. It gives you<br />access to the recovery console by booting into text mode setup, and it<br />gives you the ability to run repair installations of XP if you have<br />problems later on.<br/><br/>I hope this worked out for you and please post feedback to the comments section.<br/>Please<br />note due to the amount of comments this article has received you must<br />now click on "Post a Comment" below the existing comments to view the<br />most recent feedback in a popup window.<span style='text-decoration: underline;'/><a height='450' scrollbars='yes,width=' statusbar='1,menubar=' toolbar='0,location=' onclick=''javascript:window.open(this.href,' href='http://www.blogger.com/comment.g?blogID=37065875260840632&postID=5811530021280787235&isPopup=true'><br/></a></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-83144810447894955552008-09-05T21:34:00.001+07:002008-09-05T21:34:22.969+07:00A simple guide for implementing EWF (RAM-Reg Mode)<div xmlns='http://www.w3.org/1999/xhtml'><span style='font-weight: bold;'>1. Get the files</span><br/><br/>Download Windows XP Embedded Service Pack 2 Feature Pack 2007 from here:<br/><br/><a class='postlink' href='http://www.microsoft.com/downloads/details.aspx?FamilyID=9bdf1dea-a37e-4d25-83df-aabbaa78914f&displaylang=en'>http://www.microsoft.com/downloads/details.aspx?FamilyID=9bdf1dea-a37e-4d25-83df-aabbaa78914f&displaylang=en</a><br/><br/>Mount image (i. e. Nero ImageDrive) and open XPEFP2007.EXE using an archive manager (i. e. WinRAR). In the 'rep' directory you'll find this files: <span style='font-weight: bold;'>ewf.sys</span> and <span style='font-weight: bold;'>ewfmgr.exe</span>. Extract them. <br/><br/><span style='font-weight: bold;'>2. Copy files</span><br/><br/>ewfmgr.exe -> \windows\system32<br/>ewf.sys -> \windows\system32\drivers<br/><br/><span style='font-weight: bold;'>3. Update Windows Registry</span><br/><br/>You will need to create several keys and values:<br/><br/><span style='text-decoration: underline;'>Key name: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ewf </span><br/><br/>Name: ErrorControl<br/>Type: REG_DWORD<br/>Value: 0x00000001 (1) <br/><br/>Name: Group<br/>Type: REG_SZ<br/>Value: System Bus Extender <br/><br/>Name: Start<br/>Type: REG_DWORD<br/>Value: 0x00000000 (0) <br/><br/>Name: Type<br/>Type: REG_DWORD<br/>Value: 0x00000001 (1) <br/><br/><span style='text-decoration: underline;'>Key Name: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ewf\Parameters\Protected\Volume0 </span><br/><br/>Name: Enabled<br/>Type: REG_DWORD<br/>Value: 0 <br/><br/>Name: Type<br/>Type: REG_DWORD<br/>Value: 0x00000001 (1) <br/><br/>Name: ArcName<br/>Type: REG_SZ<br/>Value: multi(0)disk(0)rdisk(0)partition(1) <br/><br/><span style='text-decoration: underline;'>Key Name: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{71A27CDD-812A-11D0-BEC7-08002BE2092F}</span><br/><br/>Name: UpperFilters<br/>Type: REG_MULTI_SZ<br/>Value: EWF (if the value of this key is volsnap, add EWF to the value on a new line)<br/><br/>More information here: <a href='http://msdn.microsoft.com/en-us/library/ms940182.aspx' class='postlink'>http://msdn.microsoft.com/en-us/library/ms940182.aspx</a><br/>Also, I've found this interesting blog: <a href='http://granturing.blogspot.com/' class='postlink'>http://granturing.blogspot.com/</a></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-11323395759649075892008-09-05T21:33:00.001+07:002008-09-05T21:33:23.836+07:00Another solution for SSD: EWF?<div xmlns='http://www.w3.org/1999/xhtml'>I've implemented EWF (more information here: <a href='http://msdn.microsoft.com/en-us/library/ms838511.aspx' class='postlink'>http://msdn.microsoft.com/en-us/library/ms838511.aspx</a>) in Windows XP SP3. Performance now is well acceptable.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-27480165523929327532008-09-05T21:23:00.001+07:002008-09-05T21:23:05.550+07:00Steps to a happy XP experience<div xmlns='http://www.w3.org/1999/xhtml'>After installing, removing XP and installing XP again, I thought I'd outline the steps to making XP perform well.<br/><br/><ol><li>Disable D2D in Bios</li><li>Purchase and install extra 1 GB of RAM for 1.5 GB total</li><li>NLite an XP Service Pack 3 CD</li><li>Gather the Aspire One drivers. Grab the latest Intel Chipset/VGA drivers from the Intel site</li><li>Install XP, formatting the SSD to FAT32</li><li>Install the drivers </li><li>Turn off Paging</li><li>Turn off System Restore</li><li>Install Firefox 3 and you're set <img title='Smile' alt=':)' src='http://www.aspireoneuser.com/forum/images/smilies/icon_e_smile.gif'/></li></ol></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8209353169859374935.post-87737077533614864142008-09-05T09:24:00.000+07:002008-09-10T11:09:49.880+07:00Use Excel to compare two lists of data<div id="cdAppliesTo"><span class="cdAppliesToTitle">Applies to: </span><span class="cdAppliesToText"><big><big><a class="cdOAnc cdBCTCCatLink" href="http://office.microsoft.com/en-us/excel/FX100646961033.aspx" mce_href="http://office.microsoft.com/en-us/excel/FX100646961033.aspx">Microsoft Office Excel 2003</a></big></big> </span> <p>For financial record-keeping, you often have to compare two lists to<br />find data that appears on one but not on the other. Which new clients<br />need to be added to the master database? Which credit card receipts are<br />not reflected on the monthly statement, and vice versa? What checks and<br />deposits are still outstanding? It's a tedious task if you do it<br />manually. </p> <p>Microsoft Office Excel 2003 can help you perform this task faster<br />and more accurately. In many cases, you can do it even if the data is<br />not provided in a standardized form in both lists.</p> <h2>Comparing two lists of assets</h2> <p>In this article, you'll use data from the <a href="http://office.microsoft.com/search/redir.aspx?AssetID=TC011117371033&CTT=5&Origin=HA011039151033" mce_href="http://office.microsoft.com/search/redir.aspx?AssetID=TC011117371033&CTT=5&Origin=HA011039151033" class="OAnc">Compare Two Lists</a> sample datasheet to learn how an accountant could use Excel functions to compare two lists of assets — the <b class="bterm">fixed asset records</b> for a company and a <b class="bterm">property tax affidavit</b> that must be updated annually. It's a five-step process:</p> <ol><li>Make sure each asset has a unique identifier.</li><li>Find assets on the property tax affidavit that are not in the fixed asset records.</li><li>Find assets in the fixed asset records that are not on the property tax affidavit.</li><li>Sort lists to see nonmatching assets more easily.</li><li>Review nonmatching assets and check for accuracy.</li></ol> <h2>Step 1: Make sure each asset has a unique identifier</h2> <p>The following illustrations show the two lists that you want to<br />compare — a list of assets from a property tax affidavit and a list of<br />fixed asset records.</p> <p><i>Business assets on property tax affidavit and on fixed asset records</i></p> <p><img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011095921033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011095921033" alt="Property tax affidavit and fixed asset records" border="0" /></p> <p>As you see, the property tax affidavit does not have unique<br />identifiers, such as asset numbers, for each asset. But to compare<br />these lists, assets in each one must have a unique identifier. </p> <p>In this example, the best way to identify each asset is by a<br />combination of asset description and date, so you'll add a new column<br />called "Description & Date" to each list. </p> <p><b class="cntnote"> Note </b> In the Compare Asset Lists sample<br />datasheet, the property tax affidavit and the fixed asset records have<br />been copied onto one worksheet.</p> <h3>Add a "Description & Date" column to the fixed asset records</h3> <ol><li>In the Fixed Asset Records area of the worksheet, select the Asset column,<br /> and then on the <b class="ui">Insert</b> menu, click <b class="ui">Columns</b>.</li><li>In cell G2, type <b>Description & Date</b>, and then press ENTER.</li><li>Select cell G2.<br /> On the <b class="ui">Format</b> menu, click <b class="ui">Cells</b>, click the <b class="ui">Alignment</b> tab, select <b class="ui">Wrap text</b>, and then click <b class="ui">OK</b>.</li><li>In cell G3, type <b>=H3&" "&YEAR(I3)</b>. This combines the description from cell H3 and the year from cell I3 into one field.</li><li>To copy the formula from cell G3 to cell G14, select cell G3 and then drag the fill handle <img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" alt="Fill handle" border="0" /> to cell G14.</li><li>To make the column width fit the results, double-click the boundary to the right of the Description & Date column heading.</li></ol> <p><i>Fixed asset records with combined description and date in new column</i></p> <p><img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101401033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101401033" alt="Fixed asset records with combined description and date" border="0" /></p> <h3>Add a "Description & Date" column to the property tax affidavit</h3> <ol><li>In the Property Tax Affidavit area of the worksheet, select the column to the right of the Cost column, and then on the <b class="ui">Insert</b> menu, click <b class="ui">Columns</b>.</li><li>In cell E2, type <b>Description & Date</b>, and then press ENTER.</li><li>Select cell E2.<br /> On the <b class="ui">Format</b> menu, click <b class="ui">Cells</b>, click the <b class="ui">Alignment</b> tab, select <b class="ui">Wrap text</b>, and then click <b class="ui">OK</b>.</li><li>In cell E3, type <b>=C3&" "&B3</b>.</li><li>To copy the formula from cell E3 to cell E12, select cell E3, and then drag the fill handle <img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" alt="Fill handle" border="0" /> to cell E12.</li><li>To make the column width fit the results, double-click the boundary to the right of the Description & Date column heading.</li></ol> <p><i>Property tax affidavit with combined description and date in new column</i></p> <p><img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101741033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101741033" alt="Property tax affidavit with combined description and date" border="0" /></p> <p>Now that you're comparing apples to apples, you can get down to business.</p> <h2><a class="mceItemAnchor" id="step 1" name="step 1"></a>Step 2: Find assets on the property tax affidavit that are not in the fixed asset records</h2> <ol><li>In the Property Tax Affidavit worksheet, select the column to the right of the Description & Date column,<br /> and then on the <b class="ui">Insert</b> menu, click <b class="ui">Columns</b>.</li><li>In cell F2, type <b>Missing?</b>.</li><li>In cell F3, type <b>=ISNA(MATCH(E3,$I$3:$I$14,FALSE))</b>.</li><li>To copy the formula from cell F3 to cell F12, select cell F3, and then drag the fill handle <img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" alt="Fill handle" border="0" /> to cell F12.</li></ol> <p>Assets that are on the property tax affidavit but not in the fixed asset records will display <b class="ui">TRUE</b> in the Missing? column.</p> <p><i>New</i><br /> Missing? <i>column showing whether an asset is not found in other list</i></p> <p><img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101781033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101781033" alt="New Missing? column" border="0" /></p> <h2>Step 3: Find assets in the fixed asset records that are not on the property tax affidavit</h2> <ol><li>In the Fixed Asset Records worksheet, in cell M2, type <b class="ui">Missing?</b>.</li><li>In cell M3, type <b>=ISNA(MATCH(I3,$E$3:$E$12,FALSE))</b>, and then press ENTER.</li><li>To copy the formula from cell M3 to cell M14, Select cell M3, and then drag the fill handle <img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060528981033" alt="Fill handle" border="0" /> to cell M14.</li></ol> <p>Assets that are in the fixed asset records but not on the property tax affidavit will display <b class="ui">TRUE</b> in the Missing? column.</p> <h2>Step 4: Sort lists to see nonmatching assets more easily</h2> <p>To more easily see the assets that are not on both lists, you can sort the lists.</p> <p><b class="cntnote"> Note </b> If you sort the lists without first<br />following these steps to convert the formulas to values, the formulas<br />will not calculate correctly. In a large database, converting the<br />formulas to values can also help avoid long recalculation times.</p> <h3>Sort for nonmatching assets in the Property Tax Affidavit worksheet</h3> <ol><li>Drag the pointer to select cells A2 to F12.</li><li>On the <b class="ui">Edit</b> menu, click <b class="ui">Copy</b>.</li><li>On the <b class="ui">Edit</b> menu, click <b class="ui">Paste Special</b>.</li><li>In the <b class="ui">Paste Special</b> dialog box, under <b class="ui">Paste</b>, click <b class="ui">Values</b>, and then click <b class="ui">OK</b>.</li><li>On the <b class="ui">Data</b> menu, click <b class="ui">Sort</b>.</li><li>Under <b class="ui">My data range has</b>, click <b class="ui">Header row</b>; in the <b class="ui">Sort by</b> box, click <b class="ui">Missing?</b>, and then click <b class="ui">OK</b>.</li></ol> <h3>Sort for nonmatching assets in the Fixed Asset Records worksheet</h3> <ol><li>Drag the pointer to select cells H2 to M14.</li><li>On the <b class="ui">Edit</b> menu, click <b class="ui">Copy</b>.</li><li>On the <b class="ui">Edit</b> menu, click <b class="ui">Paste Special</b>.</li><li>In the <b class="ui">Paste Special</b> dialog box, under <b class="ui">Paste</b>, click <b class="ui">Values</b>, and then click <b class="ui">OK</b>.</li><li>On the <b class="ui">Data</b> menu, click <b class="ui">Sort</b>.</li><li>Under <b class="ui">My data range has</b>, click <b class="ui">Header row</b>; in the <b class="ui">Sort by</b> box, click <b class="ui">Missing?</b>, and then click <b class="ui">OK</b>.</li></ol> <p>You can now easily see which assets may need to be added or deleted to update the property tax affidavit.</p> <p><i>Property tax affidavit and fixed asset records sorted by</i><br /> Missing? <i>column</i></p> <p><img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101801033" mce_src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA011101801033" alt="Property tax affidavit and fixed asset records sorted by Missing? column" border="0" /></p> <h2>Step 5: Review nonmatching assets and check for accuracy</h2> <p>Before you update the property tax affidavit, it's a good idea to<br />manually review the nonmatching assets — which is fortunately a lot<br />faster than manually comparing the entire list. Review the nonmatching<br />assets and determine why they don't match. Were the assets retired or<br />sold? Are they new assets that should be added, or are they assets that<br />are not required to be reported on the affidavit? Or did the assets<br />fail to find a match because of misspellings or other errors?</p> <h2>Other ways to prepare data for matching</h2> <p>Sometimes the data in two lists must be standardized before Excel<br />can compare the lists. In the preceding example, the dates in one list<br />were converted to years, and two fields were combined into one. The<br />following table shows common data inconsistencies and suggested Excel<br />functions that you can use to prepare data for matching. </p> <table class="collapse mceItemTable"> <tbody> <tr class="trbgeven"> <th>Problem</th> <th>Example</th> <th>How to modify</th> </tr> <tr class="trbgodd"> <td>Inconsistent abbreviations</td> <td>Litware, Inc.<br />vs. Litware, Incorporated</td> <td>Use the LEFT function to create a field with only the number of characters from the left that you specify.</td> </tr> <tr class="trbgeven"> <td>Extra numbers or characters on one list</td> <td>12345 vs. 12345-1033</td> <td>Use the LEFT or RIGHT functions to create a field with only the number of characters from the left or right that you specify.</td> </tr> <tr class="trbgodd"> <td>Imprecise numbers caused by estimates, rounding variances, or sales tax</td> <td>$12,000 vs. $12,011</td> <td>Use the ROUND function to create a field with comparable amounts.</td> </tr> <tr class="trbgeven"> <td>Extra spaces</td> <td>Jae B. Pak vs. Jae B. Pak</td> <td>Use the TRIM function to remove all spaces from text except single spaces between words.</td> </tr> </tbody> </table> <p><span class="cdAppliesToText"><br /></span></p></div>Unknownnoreply@blogger.com0