PHP tutorial- alias directory


Alias Directory

In this tutorial, you will learn to create Apache alias directory in WampServer. Typically, if you do not create a alias directory, you need to place your php files in the www directory of WampServer to be able to execute them on a web broswer. The alias directory allows you to save your web page files in a directory of your choice rather than www directory and have a url point to that directory. For example, a url that points to the d:/mysite directory can be http://localhost/healthtips/. To accomplish this task, first you need to create mysite directory in drive D. You will place your web page files in the mysite directory. For this tutorial, you can create a PHP page called helloworld.php and save it in the mysite directory. It simply displays the Hello World message. Then on the task bar or in the Notification Area Icon, select WampServer icon wampserver icon ->Apache-> Alias Directories->Add an alias.

apache alias directory

You will get a console window as shown below. You are asked to enter the alias for the url to point to mysite directory. Simply type healthtips for the alias.

create alias directory

By pressing Enter key, you will see another console window as shown below. In this window, you need to enter the full path of the mysite directory (d:/mysite/). After you press Enter key, the alias is created for you.

point to mysite directory

To test the alias, open your web browser and type the following url: http://localhost/healthtips/helloworld.php. The helloworld.php will be executed and the Hellow World text is displayed as shown in the image below.

alias action on web browser

Alternatively, you can create an alias directory by using the httpd.conf file of Apache (WampServer icon->Apache->httpd.conf). You need to append the following code to the httpd.conf file.

Alias /healthtips "D:/mysite/"
<Directory "D:/mysite/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>


Comments





This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.