Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

some help needed with PHP!

11 like 0 dislike
Recently I noticed some issues for one of my sites' pages listed in Yahoo! index. I have a hosting account where is host 2 domains, 1 is an addon domain and points to a subdomain of the main domain of the account.
Something like this: main domain of the account is domain.com and the second domain ( domain2.com ) points to sd.domain.com.
Now the problem is that I have many directories for domain2.com which in order to work properly need an ending "/" ( like: www*domain2*com/directory/ not www*domain2*.com/directory ) which Yahoo! picked up without the ending "/" and shows them in the serps without it like: www*domain2*.com/directory , and when surfers click on it they get and error page . I see no problem with Google which picked them with the ending "/" .

I asked the same question on SEOCHAT and a nice member gave me a solution, something like this:
Code:
<?
$requested_domain = $_SERVER['SERVER_NAME'];
$requested_page = $_SERVER['REQUEST_URI'];

if ($requested_domain == "subdomain.maindomain.com") {
header("Location: http://www.addondomain.com/".$requested_page);
}

?>
but at that moment I didn't pay to much attention because I though it will work ( my bad mistake  )

Now, it seems it doesn't so if anyone can give me a clue on this I would be very thankful.
asked 1 year ago by webmaster (25,380 points)

1 Answer

1 like 0 dislike
 
Best answer
Are you just wanting to add a slash to the end of the URL?

If so, something like this may work...

php Code:
<?
if (substr ($_SERVER['REQUEST_URI'], -1) != "/") header ("Location: http://" . $_SERVER['SERVER_NAME'] . "/" . $_SERVER['REQUEST_URI'] . "/"
?>
answered 1 year ago by monirulislam (51,620 points)

Related questions

10 like 0 dislike
1 answer
9 like 0 dislike
1 answer
7 like 0 dislike
1 answer
asked 2 years ago by eagle09 (95,490 points)
7 like 0 dislike
1 answer
asked 2 years ago by eagle09 (95,490 points)
9 like 0 dislike
1 answer