RSS

.htaccess redirect based on requested domain

Wed, May 7, 2008

0 Comments

I often use the following .htaccess / mod_rewrite solution to redirect domain names based on the requested domain. The reasons for this are many. Most recent example for me is I had a single site with 5 alias domains but software licensed for only one. Even though I had the alias domains set up on the server it still did not satisfy the license. Add the line below to htaccess and now no matter which of the 5 domains are written in they are re-written to the one with the licence (need to duplicate for each domain). The license is valid since its all the same physical website and everyone is happy. Brilliant!

I am sure there is a more eloquent way of accomplishing this with mod_rewrite - but this gets the job done!

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com [NC]
RewriteRule ^(.*)$ http://otherdomain.com/$1 [R=301,L]
 

Can also be used to redirect to a landing page based on the requested domain:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.domain.com
Rewriterule ^(.*)$ http://www.any-domain.com/landing-page.html [L]
 

Have a better solution? I’m no mod_rewrite guru so comments are always welcome!

Continue reading...

Desktop Tower Defense

Sat, Apr 26, 2008

0 Comments

This game is soo addicting. You have been warned - click on the following image at your own risk :)

desktop_tower_defense.jpg

Continue reading...

Animator vs Animation

Sat, Apr 26, 2008

0 Comments

For the Flash animators out there…

You need to a flashplayer enabled browser to view this YouTube video

Originally found here by Alan Becker.

Continue reading...

Joomla 1.0.x Writeable Directories

Fri, Apr 18, 2008

2 Comments

The following is a list of the directories that must be ‘writeable’ for Joomla 1.0.x to work properly. I’m including it here as a reference. In most cases individuals that install Joomla will simply chmod the permissions for these directories to 707 or 777. I have found through personal experience that this is not very secure (using 707 or 777 anywhere on your site allows a ‘hacker’ who may find a vulnerable script to upload anything they want to your server - aka ebay/paypal spoof sites, etc).

I have found a few solutions, but have not implemented any as of yet. The most promising looks like mod_suphp (aka PHPsuexec). I will post my solution to this issue once it is fully tested. In the mean time I am setting all directories to 755 and files to 644 and temporarily changing them when needed.

administrator/backups/         
administrator/components/       
administrator/modules/         
administrator/templates/       
cache/                         
components/            
images/                
images/banners/                
images/stories/                
language/                      
mambots/                       
mambots/content/       
mambots/editors/       
mambots/editors-xtd/           
mambots/search/                
mambots/system/                
media/                         
modules/               
templates/             
 
Continue reading...

Perfect Permissions for Joomla and Plesk

Fri, Apr 18, 2008

3 Comments

This post is a continuation (actually a better solution) from my previous post on Joomla Session Save Path

The solution is a slightly modified version from the original post found at rackerhacker.com

Change the umask in ‘/etc/proftpd.conf’ from ‘022′ to ‘002′.

Then, update the directory permissions by running the following at the command line:

cd /var/www/vhosts/[domain.com]
chown -R [username]:psacln httpdocs
chmod -R g+w httpdocs
find httpdocs -type d -exec chmod g+s {} \;
 

Add the ‘apache’ user to the ‘psacln’ group by editing ‘/etc/group’.

Change

psacln:x:2524:
 

to

psacln:x:2524:apache
 

For my server I also had to add psaftp,psaadm:

psacln:x:2524:apache,psaftp,psaadm
 

Joomla also complains about some PHP settings, sometimes including not being able to write to ‘/var/lib/php/session’. To fix the issues, make some adjustments to the ‘/var/www/vhosts/[domain]/conf/vhost.conf’ for the domain (you may have to create this file):

<Directory /var/www/vhosts/[domain]/httpdocs>
php_admin_flag magic_quotes_gpc on
php_admin_flag display_errors on
php_admin_value session.save_path /tmp
</Directory>
 

If the vhost.conf is brand new, then run:

/usr/local/psa/admin/bin/websrvmng -av
 

Make sure Apache runs with your new configuration:

# httpd -t (check your work)
# /etc/init.d/httpd reload (service httpd restart on my server)
 

Done! No more errors on the install screen and no more apache/ftpuser issues with uploading files.

Continue reading...
Older Entries Newer Entries