Archive for the ‘Scripting / Coding’ Category

How to set 303 (replaced) redirection?

1. Login to DirectAdmin server control panel.
2. Locate the link ‘Site Redirection’.
3. In Local URL Path enter the directory or file name which should be redirected.
4. Select ‘redirect type’, in this case you will choose 303 (replaced).
5. Enter destination URL where file or directory should be redirected.

To review and delete any of redirection you can repeat the same two steps.

How to set 302 (temporary) redirection?

1. Login to DirectAdmin server control panel.
2. Locate the link ‘Site Redirection’.
3. In Local URL Path enter the directory or file name which should be redirected.
4. Select ‘redirect type’, in this case you will choose 302 (temporary).
5. Enter destination URL where file or directory should be redirected.

To review and delete any of redirection you can repeat the same two steps.

How to set 301 (permanent) redirection?

1. Login to DirectAdmin server control panel.
2. Locate the link ‘Site Redirection’.
3. In Local URL Path enter the directory or file name which should be redirected.
4. Select ‘redirect type’, in this case you will choose 301 (permanent).
5. Enter destination URL where file or directory should be redirected.

To review and delete any of redirection you can repeat the same two steps.

How to set custom error page in DirectAdmin?

1. Create your custom error page. This could be for 500 error (internal server error), 404 error (page not found), 403 error (forbidden), 401 error (authorization required), 400 error (bad request).
2. Login to DirectAdmin server control panel.
3. Locate link Custom Error Pages.
4. Choose any file to edit for certain error page.
5. Paste your web page source code to the editor and click Save As.

The same steps valid for every error code. Alternatively you can select error page for each directory by creating .htaccess file in each directory (if there is no .htaccess file).
Copy this line to the end of your .htaccess file:
ErrorDocument 401 http://yourdomain.com/nopassword.html

This code should be for each error you want to set the custom page. Reemember use the correct editor to edit .htaccess (e.g. Notepad ++).

How to set the cronjobs in DirectAdmin?

To set the cronjob for your website processes you need to:
1. Login to DirectAdmin server control panel.
2. Locate the link Cronjobs.
3. Add values accordingly to the instructions given bellow:
Valid cron time values are the numbers indicated and *.
You can specify exact times using commas to separate them. eg: 1,2,3 (minutes 1,2 and 3)
You can specify spans using a dash. eg: 5-7 (minutes 5 to 7)
You can specify intervals using a star and a forward slash. eg: */2 (every 2nd minute)
You can combine them to create a more precise schedule. eg: 1,5,11-15,30-59/2 (minutes 1, 5, 11 to 15 and every 2nd minute between 30 and 59)
Note that there are no spaces

To review or remove your cronjobs you can repeat first 2 steps.

How to create MySQL database in DirectAdmin?

In order to create MySQL database which is essential thing for most CMS and blog systems you must:
1. Login to DirectAdmin server control panel.
2. Locate MySQL Management.
3. Click on Create new Database.
4. Enter Database Name, Database Username, Username Password, Confirm Password.
5. Click Create.

How to check installed Perl modules?

To check Perl modules you need to:
1. Login to DirectAdmin server control panel.
2. Locate the link Installed Perl Modules.
3. The list will be loaded with installed Perl modules.

How to order the results of MySQL query?

Usually most of the work done with MySQL involves pulling down data from a MySQL database. In MySQL, data is retrieved with the “SELECT” keyword. Think of SELECT as working the same way as it does on your computer. If you wanted to copy some information in a document, you would first select the desired information, then copy and paste.

How to limit the number of rows returned in MySQL?

MySQL supports the LIMIT keyword, which allows you to control how many rows are returned; ideal when displaying data over many pages. You can use LIMIT in your sql query like this:

SELECT name FROM table LIMIT 10

if you want to get the rows between 10 and 20 do the following:

SELECT name FROM table LIMIT 9, 10

How to insert the date into MySQL table?

Specifying the dates on which the content is entered is of prime importance for the structuring and the chronological arrangement of articles, posts and replies in a dynamic website. MySQL comes with several data types for storing dates in its database system: DATE, TIMESTAMP, DATETIME and YEAR.

The default way to store a date in a MySQL database is by using DATE. The proper format of a DATE is: YYYY-MM-DD. If you try to enter a date in a format other than the Year-Month-Day format, it might work but it won’t be storing the dates as you expect.

In order to run a MySQL Insert command and add the current date into your table you can use MySQL’s built-in function CURDATE() in your query.