Use PHP to Create Symbolic Links without Shell Access
[ Keywords: symbolic, links, symlinks, symlink, shell, access, php ]
On Unix systems, a symbolic link refers to a file that points to another file or directory. Symbolic links serve as powerful tools for web designers and developers. Using shell access, creating a symbolic link requires only one line of code:
ln -s /home/username/public_html/directory1 /home/username/public_html/directory2
Simple enough. Assuming you have access to the linux shell. Unfortunately, many shared hosting environments deny shell access. Fortunately, creating symbolic links — also called “symlinks” — remains a possibility via the PHP symlink() function. Check it out..
Symbolic Links via PHP:
Edit, copy & paste the following line of code into a PHP (.php) file and upload it to the root directory on your server (i.e., the directory that contains “public_html”):
<?php symlink('/home/username/public_html/directory1', '/home/username/public_html/directory2'); ?>
Next, trigger the function by calling the PHP file via your browser. If you see a blank page, you are good to go — the symbolic link has been created according to the specified parameters. To create another symbolic link, simply edit the parameters and repeat the process.
Related articles
- Display the Total Number of WordPress Posts, Comments, and Categories
- Auto Clear and Restore Form Elements
- Industrial-Strength Spamless Email Links
- Go Back via JavaScript and PHP
- Another Mystery Solved..
- MySQL Magic: Find and Replace Data
- Super Loop: Exclude Specific Categories and Display any Number of Posts
About this article
This is article #360, posted by Perishable on Monday, June 25, 2007 @ 10:25am. Categorized as Function, and tagged with links, linux, php, tips, tricks. Updated on November 06, 2007. Visited 15661 times. 2 Responses »
Bookmark • Subscribe • Explore
« SEO 101: Best Practices • Up • Ultimate htaccess Blacklist »
1 • July 3, 2007 at 6:14 am — Tiagotb says:
Very thanks…
this tutorial help-me a lot =D