From the category archives:

.htaccess

Programmatically determine Joomla homepage

by Caroline on March 17, 2007

If both mod_rewrite and 301’s are out in full force the home page is not going to be identifiable by a Server query_string containing “frontpage.” To determine if the current code is on the home page:

$s = filter_var($_REQUEST['QUERY_STRING'], FILTER_SANITIZE_SPECIAL_CHARS);
if (empty($s)) {

//you’re on the home page

}

{ 0 comments }

#Redirect any bogartcomputing.com request to http://www.bogartcomputing.com
rewritecond %{HTTP_HOST} ^bogartcomputing\.com
rewriterule (.*) http://www.bogartcomputing.com/$1 [R=301,L] 
#Redirect any index.php request to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php /$1 [R=301,L]
#redirect any home/ request to /
RewriteRule ^(.*)home/ /$1 [R=301,L]

{ 0 comments }

Question: how to use cpanel to host multiple web sites, each of which has multiple domans associated with it.

Example:

Assumptions: Name server setup points all of these domains to the name server where site1domain1.com etc. are hosted; site1domain1.com has content in /home/site1domain1/public_html; site1domain1 is “main” cpanel site, a Mother Site.

site1domain1.com has web content for site1domain1.com
site1domain2.com has pointer to site1domain1.com

site2domain1.com
site2domain2.com has pointer to site2domain1.com

/home/site1domain/public_html:                       site 1 domain 1’s content
/home/site1domain/public_html/site1domain2: site 1 domain 2 is pointer to site 1 domain 1
/home/site1domain/public_html/site2domain1: site 2 domain 1’s content
/home/site1domain/public_html/site2domain2: site 2 domain 2 is pointer to site 2 domain 1

Answer:

site1domain1.com is the host cpanel’s “main” site. It has a public_html directory under which its web code resides. Make sure none of the following directory names exist under public_html:

/home/site1domain1/public_html:
site1domain2
site2domain1
site2domain2

Task #1:
Make site1domain2.com point to site1domain1.com

Go to Addon Domains. Enter
site1domain2.com
site1domain2
a password here
Click Add Domain

This action creates the physical directory /home/site1domain1/public_html/site1domain2

New Domain Name:
Username/directory/subdomain Name:
Password:
 

Point site1domain2.com to site1domain1.com 
Go to Addon Domains.
At Redirect Domain to URL select site1domain2.com
Click Setup Redirect
Enter http://site1domain1.com/
Click Save

In browser go to site1domain1.com, it should show content in public_html
In browser go to site1domain2.com, it should redirect to site1domain1.com

Task #2:
Make site2domain2.com point to site2domain1.com

This is different than task #1 because there we were redirect the main hosting site’s domain. Here we are creating an add-on domain, redirecting it from the main site to the site2domain1 content, and then creating a pointer URL that redirects to site2domain1 as well.

Summary of tasks:
Create site2domain1 add on domain, redirect it so it displays site2domain1 content, create site2domain2 add on domain, redirect it so it lands at site2domain1.com

Create physical directory /home/site1domain1/public_html/site2domain1
Go to Addon Domains. Enter
site2domain1.com
site2domain1
a password here
Click Add Domain

Create physical directory /home/site1domain/public_html/site2domain2
Go to AddOn Domains. Enter
site2domain2.com
site2domain
a password here
Click Add Domain

 

Go to AddOn Domains
At Redirect Domain to URL select site2domain1.com
Click Setup Redirect
Enter http://site1domain1.com/site2domain1.com
Click Save
Go to AddOn Domains
At Redirect Domain to URL select site2domain
Enter http://site1domain1.com/site2domain1.com
Click Save
 

{ 0 comments }

Answers the question:
How to redirect domains given tools .htaccess, parked domain redirect and Joomla component 404sef.

If you use Joomla and care at all about search engine rankings you’ll have to use a SEF translation of some kind. I chose 404sef and I’m grateful for what it does. Here’s how to get around something it doesn’t do, which is handling non-primary domains.
It will make Search Enging Friendly links for the current domain, but if you redirect a different domain to the 404Sef’d one the component will cough up a hair ball.

Setup:

  1. Joomla 1.0.10
  2. Siteground.com hosting cpanel with parked domains
  3. Global config: SEF on
  4. SEF404 config: SEF on
  5. secondary domains that need to redirect in a search engine friendly way to http://www.bombshelters.com/:

biologicalprotection.com
biologicalshelter.com
biologicalshelter.us
biologicalshelters.com
biologicalshelters.us
blastshelters.com
blastshelters.us
bombshelter.us
chemicalprotection.us
combatshelter.com
disastershelter.com
falloutshelter.us
governmentprotection.com
nbcshelter.com
nbcshelter.us
nuclearprotection.us
nuclearshelter.us
nuclearshelters.com
radiusdefense.com
radiusengineering.us
radiusengineeringinternational.com
radiusengineeringintl.com
radiusshelters.com
saferoomprotection.us
shelterengineering.com
shelterprotection.us
sheltersystems.us
survivalshelter.us
survivalshelters.us
undergroundshelter.us
undergroundshelterengineering.com
undergroundshelters.com
undergroundshelters.us
wmdprotection.us
Setup secondary domains to resolve to primary domain

These domains are all registered on network solutions. I changed the primary and secondary name servers on all of them to the siteground name server for bombshelters.com. Then on cpanel for bombshelters.com I used the “parked domains” tool to point each of the domains to bombshelters.com.

This worked, and then broken suddenly tonight. It actually probably broke when I installed 404SEF I just didn’t realize it.

Symptoms

I guess I had 404SEF off when I redirected the domains to the bombshelters.com name server because m initial tests worked great. You’d type undergroundshelter.us and the browser would display bombshelters.com content under the undergroundshelter.us address bar. When I tried that tonight I got “this page cannot be displayed.”

The pubic_html errorlog pointed to:

[24-Jul-2006 00:58:57] PHP Warning: strpos() []: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83

[23-Jul-2006 23:04:24] PHP Fatal error: Call to undefined function: sefreltoabs() in /home/bombshel/public_html/components/com_content/content.html.php on line 584

Things that don’t fix the problem

  1. Turning off 404SEF: it fixes the problem but creates the old problem of unfriendly URLs
  2. Ensuring the strpos delimiter (and target) are not empty on sef404.php:
  3. [24-Jul-2006 00:58:57] PHP Warning: strpos() [function.strpos]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83

    bold line below is line 83

    if (!empty($pathdata) && (!empty($sefconfig->suffix)))

    {
    if (strpos($pathdata,$sefconfig->suffix) !== false)
    $path_array[$x] = str_replace($sefconfig->suffix,”",$pathdata);
    $x++;
    }

    This is fine as far as it goes, it’s good to test inputs before assuming they have content, but it addresses a symptom, not a problem.

  4. Similar to #2, defining sefRelAbs function against its will

]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83content.html.php:
if (!function_exists(’sefRelToAbs’))
{
function sefRelToAbs($string) {}
}
What does work

In .htaccess rewrite any domain that is not http://www.bombshelters.com/ to be http://www.bombshelters.com/. Works for “bombshelters.com” (without www), “falloutshelter.us,” and etc. secondary domains.
RewriteCond %{HTTP_HOST} !bombshelters.com$ [NC]
RewriteRule ^(.*)$ http://bombshelters.com/$1 [L,R=301]

Big thank you to http://enarion.net/web/apache/htaccess/redirect-www-and-no-www/

 

{ 0 comments }