Forum Moderators: phranque
[my-site.com...]
[my-site.com...]
[my-site.com...]
[my-site.com...]
[my-site.com...]
[my-site.com...]
Can I place directives in the Apache httpd.conf virtual host configuration or .htaccess file?
Many thanks in advance for any advice.
I want to use "http://www.example.com/home.php" as my consistent home page URL.
WHY?
1. If you ever migrate your site to a different technology (e.g. ASP.Net), you'll have to change your homepage URI.
2. If you get inbound links, it's unlikely that they will all reference http://www.example.com/home.php - most people would assume that http://www.example.com/ is the home page of a site.
Read the W3C's page Cool URIs don't change [w3.org]
Perhaps you should consider using http://www.example.com/ - it's the "standard" way to do this, after all...
Coming back to the httpd.conf file directives, how do I make Apache enforce this consistent URL?
Our httpd.conf file currently has the following directives for this domain:
<virtualhost www.my-site.co.uk>
ScriptAlias /cgi-bin/ /www/#*$!/cgi-bin/
ScriptAlias /cgi-#*$!1/ /www/#*$!1/cgi-bin/
User xxx
Group xxx
ServerAdmin webmaster@my-site.co.uk
ServerName www.my-site.co.uk
ErrorDocument 404 /missing.html
DocumentRoot /www/xxx1
DirectoryIndex home.php
LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
TransferLog logs/xxx-access-log
</virtualhost>
Set up a second virtualhost for the servername example.com, set it to serve content from a DIFFERENT directory to www.example.com, and in this directory put a .htaccess file like this:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
If a visitor requests http://example.com/content.html it triggers mod_rewrite to issue a 301 Moved Permanently redirect to http://www.example.com/content.html