1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Friday, August 6, 2010

Apache Custom Error Messages

http://www.htmlcenter.com/blog/apache-custom-error-messages/

You log onto your shell and create a file called .htaccess in your document root. Let's assume that you want to display a custom error page for "File not found"-errors (code: 404).

Put the following code inside the .htaccess:


ErrorDocument 404 /path/to/error/document.html


Save it. Viola! It's all done.

You may also refer to a remote document:


ErrorDocument 404 http://errors.domain.com/404.php


The syntax is as follows:


ErrorDocument <3-digit-code> action


Can't get enough of them?

Successful Client Requests
200OK
201Created
202Accepted
203Non-Authorative Information
204 No Content
205Reset Content
206Partial Content
Client Request Redirected
300Multiple Choices
301Moved Permanently
302 Moved Temporarily
303See Other
304Not Modified
305 Use Proxy
Client Request Errors
400Bad Request
401 Authorization Required
402Payment Required (not used yet)
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable (encoding)
407Proxy Authentication Required
408Request Timed Out
409 Conflicting Request
410Gone
411Content Length Required
412Precondition Failed
413Request Entity Too Long
414Request URI Too Long
415Unsupported Media Type
Server Errors
500 Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported

Have fun!

Thursday, August 5, 2010

Apache mod_rewrite Introduction

http://httpd.apache.org/docs/2.2/rewrite/rewrite_intro.html#page-header
(I followed this guide to create my .htaccess, HL 20100805)


The Apache module mod_rewrite is a very powerful and sophisticated module which provides a way to do URL manipulations. With it, you can do nearly all types of URL rewriting that you may need.

Remember that many common URL-manipulation tasks don't require the full power and complexity of mod_rewrite. For simple tasks, see mod_alias and the documentation on mapping URLs to the filesystem.

Finally, before proceeding, be sure to configure the RewriteLog. Although this log file can give an overwhelming amount of information, it is indispensable in debugging problems with mod_rewriteconfiguration, since it will tell you exactly how each rule is processed.

top

Regular Expressions

mod_rewrite uses the Perl Compatible Regular Expression vocabulary. In this document, we do not attempt to provide a detailed reference to regular expressions. For that, we recommend the PCRE man pages, the Perl regular expression man page, and Mastering Regular Expressions, by Jeffrey Friedl.

Regex vocabulary

The following are the minimal building blocks you will need, in order to write regular expressions and RewriteRules.

Character Meaning Example
. Matches any single character c.t will match cat, cot, cut, etc.
+ Repeats the previous match one or more times a+ matches a, aa, aaa, etc
* Repeats the previous match zero or more times. a* matches all the same things a+ matches, but will also match an empty string.
? Makes the match optional. colou?r will match color and colour.
^ Called an anchor, matches the beginning of the string ^a matches a string that begins with a
$ The other anchor, this matches the end of the string. a$ matches a string that ends with a.
( ) Groups several characters into a single unit, and captures a match for use in a backreference. (ab)+ matches ababab - that is, the +applies to the group. For more on backreferences see below.
[ ] A character class - matches one of the characters c[uoa]t matches cut, cot or cat.
[^ ] Negative character class - matches any character not specified c[^/]t matches cat or c=t but not c/t

In mod_rewrite the ! character can be used before a regular expression to negate it. This is, a string will be considered to have matched only if it does not match the rest of the expression.

Regex Back-Reference Availability

One important thing here has to be remembered: Whenever you use parentheses in Pattern or in one of the CondPattern, back-references are internally created which can be used with the strings$N and %N (see below). These are available for creating the strings Substitution and TestString. Figure 2 shows to which locations the back-references are transferred for expansion.

[Needs graphics capability to display]

Figure 2: The back-reference flow through a rule.

  • back-references ($N) to the RewriteRule Pattern
  • back-references (%N) to the last matched RewriteCond CondPattern

top

RewriteRule basics

A RewriteRule consists of three arguments separated by spaces. The arguments are

  1. Pattern: which incoming URLs should be affected by the rule;
  2. Substitution: where should the matching requests be sent;
  3. [flags]: options affecting the rewritten request.

The Pattern is always a regular expression matched against the URL-Path of the incoming request (the part after the hostname but before any question mark indicating the beginning of a query string).

The Substitution can itself be one of three things:

A full filesystem path to a resource

RewriteRule ^/games.* /usr/local/games/web

This maps a request to an arbitrary location on your filesystem, much like the Aliasdirective.

A web-path to a resource

RewriteRule ^/foo$ /bar

If DocumentRoot is set to /usr/local/apache2/htdocs, then this directive would map requests for http://example.com/foo to the path/usr/local/apache2/htdocs/bar.

An absolute URL

RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]

This tells the client to make a new request for the specified URL.

The Substitution can also contain back-references to parts of the incoming URL-path matched by the Pattern. Consider the following:

RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1

The variable $1 will be replaced with whatever text was matched by the expression inside the parenthesis in the Pattern. For example, a request forhttp://example.com/product/r14df/view will be mapped to the path/var/web/productdb/r14df.

If there is more than one expression in parenthesis, they are available in order in the variables $1,$2, $3, and so on.

top

Rewrite Flags

The behavior of a RewriteRule can be modified by the application of one or more flags to the end of the rule. For example, the matching behavior of a rule can be made case-insensitive by the application of the [NC] flag:

RewriteRule ^puppy.html smalldog.html [NC]

For more details on the available flags, their meanings, and examples, see the Rewrite Flagsdocument.

top

Rewrite conditions

One or more RewriteCond directives can be used to restrict the types of requests that will be subject to the following RewriteRule. The first argument is a variable describing a characteristic of the request, the second argument is a regular expression that must match the variable, and a third optional argument is a list of flags that modify how the match is evaluated.

For example, to send all requests from a particular IP range to a different server, you could use:

RewriteCond %{REMOTE_ADDR} ^10\.2\.
RewriteRule (.*) http://intranet.example.com$1

When more than one RewriteCond is specified, they must all match for the RewriteRule to be applied. For example, to deny requests that contain the word "hack" in their query string, except if they also contain a cookie containing the word "go", you could use:

RewriteCond %{QUERY_STRING} hack
RewriteCond %{HTTP_COOKIE} !go
RewriteRule .* - [F]

Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".

Matches in the regular expressions contained in the RewriteConds can be used as part of theSubstitution in the RewriteRule using the variables %1, %2, etc. For example, this will direct the request to a different directory depending on the hostname used to access the site:

RewriteCond %{HTTP_HOST} (.*)
RewriteRule ^/(.*) /sites/%1/$1

If the request was for http://example.com/foo/bar, then %1 would contain example.comand $1 would contain foo/bar.

top
top

.htaccess files

Rewriting is typically configured in the main server configuration setting (outside any<Directory> section) or inside <VirtualHost> containers. This is the easiest way to do rewriting and is recommended. It is possible, however, to do rewriting inside <Directory>sections or .htaccess files at the expense of some additional complexity. This technique is called per-directory rewrites.

The main difference with per-server rewrites is that the path prefix of the directory containing the.htaccess file is stripped before matching in the RewriteRule. In addition, the RewriteBaseshould be used to assure the request is properly mapped.

Wednesday, August 4, 2010

How to Set Up A Custom 404 File Not Found Page on Apache

http://webdesign.about.com/od/apache/ht/ht404apache.htm
  1. Create a Web page that will be your 404 document.
  2. Open yourhttpd.conffile or .htaccess for editing.
  3. Find the line that reads (or add the line)
     ErrorDocument 404 /404.html
  4. Change the third entry to the URI you would like to display, e.g.
     ErrorDocument 404 /new_404.html
  5. Restart your Web server if necessary.

PayPal's 5 TIPS FOR SELLING INTERNATIONALLY

https://www.paypal-marketing.ca/merchantservices/en/5-tips-to-increase-international-sales.html

1. Focus on English Language Markets First
2. Make Customers Feel Welcome
3. Simplify the Purchasing Process
4. Get the Shipping Right
5. Localize Customer Service


Friday, July 30, 2010

How to View bash shell history and Change bash history file size in Ubuntu

http://www.ubuntugeek.com/how-to-view-bash-shell-history-and-change-bash-history-file-size-in-ubuntu.html?utm_source=rss&utm_medium=rss&utm_campaign=how-to-view-bash-shell-history-and-change-bash-history-file-size-in-ubuntu

The Bash shell is the default shell environment in most Linux distributions, including all flavours of Debian. One default feature of the Bash shell is to record a history of all the commands entered by a user in a log file called .bash_history, found in the user's home directory.
View user bash history in Ubuntu

First open up a terminal from Applications > Accessories > Terminal and type the following command

history

This will show you all your terminal commands history on the terminal

If you want to save this history in to a file use the following command

history -w ~/userhistory.txt

Once you have save the file you can view using the following command from your terminal

gedit ~/userhistory.txt

Change bash history file size

If you want to change bash history file size open up your .bashrc using the following command from your terminal

gedit ~/.bashrc

Now add the following line at the top

export HISTFILESIZE=3000

Save and exit the file

As you can see, the limit can be changed.

Bash shell keeps it's own history in a file. You can view that file as stated before, or by opening ~/.bash_history.

Tuesday, July 27, 2010

Latest ATI Video Driver Has Support for Ubuntu 10.04 - ATI Eyefinity is also included in ATI Catalyst 10.7

http://news.softpedia.com/news/Latest-ATI-Video-Driver-Has-Support-for-Ubuntu-10-04-149158.shtml

Advanced Micro Devices (AMD) proudly announced a few minutes ago, July 26th, another improved version of its ATI Catalyst Linux display driver, available for both x86 and x86_64 architectures. ATI Catalyst 10.7 introduces final and stable support for the Ubuntu 10.04 LTS (Lucid Lynx) operating system, early support for the newly released openSUSE 11.3 distribution, and official support for the ATI Eyefinity technology. The software version was updated to 8.753. Without further introduction, let's have a look at the highlights of ATI Catalyst 10.7:

· Production support for Ubuntu 10.04 LTS (Lucid Lynx) operating system;
· Initial support for the openSUSE 11.3 operating system;
· Support for the ATI Eyefinity technology on all supported Linux systems;
· Fixed startup X segmentation fault issue on Ubuntu 10.04 LTS, for multi-ASIC systems;
· The display no longer turns black when display rotation is applied from XRandR or the Catalyst Control Center;
· Solved Catalyst Control Center startup issue after X restart, when a primary display was disabled (dual-head/clone mode);
· Users of two Gemimi cards can now properly enable CrossFire on the first card;
· Fix Xorg Server crash when the "Maintain Aspect Ratio" option is applied at the maximum resolution (GPU scaling);
· Fixed display rotation issue in SUSE Linux;
· Fixed X-window crash when an ATI video card is plugged in a NV's C51 IGP (Integrated Graphics Processor) motherboard;
· Clone mode now works properly if the Fn+F4 key combination is pressed, after an external VGA monitor was connected;
· Fixed display issues in Catalyst Control Center, when the Gamma control was changed, for clone mode;
· Fixed black screen and X-window startup issues when a second ASIC is enabled, and a monitor is not connected.

As usual, some known issues remain unresolved in this release, so make sure you check them out here.

Requirements:
· Red Hat Enterprise Linux (RHEL) suite;
· Novell/SuSE and openSUSE Linux product suite;
· Ubuntu Linux (including 10.04 LTS (Lucid Lynx)).
· XOrg 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4 or 7.5;
· Linux kernel 2.6 or above;
· glibc version 2.2 or 2.3;
· POSIX Shared Memory (/dev/shm) support is needed for 3D applications;
· You need all of these packages before installing: XFree86-Mesa-libGL, libstdc++, libgcc, XFree86-libs, fontconfig, freetype, zlib and gcc;
· For the best experience, you should also have: the kernel module build environment, either the sources or the headers, and, if you plan to use the RPM packages, you need to make sure the RMP utility is working properly.

Detailed installation instructions can be found here, in PDF format.

Download the ATI/AMD Linux Display Driver 10.7 right now fromSoftpedia.


电子书下载网站

http://www.williamlong.info/blog/archives/492.html

  电子书下载网站

  看书多了,尤其是有了iPad之后,就喜欢看电子书了。下面是我找到的一些电子书和盗版书的下载网站。

  PDF/DOC格式电子书下载网站:

  1、 www.docin.com

  2、 wenku.baidu.com

  3、 ishare.iask.sina.com.cn

  EPUB格式电子书下载网站:

  1、 www.shucang.com

  2、 www.cnepub.com

  3、 www.coay.com

  4、 bbs.weiphone.com/thread-htm-fid-224.html

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...