Web Hosting Forum | Lunarpages
News: July 14, 2008 - New Contest! - Submit Your WordPress Theme Designs, Win BIG!
June 30, 2008 - Submit Your Site for the July 08 Site of the Month Award!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 25, 2008, 05:54:38 PM


Login with username, password and session length


Pages: 1 [2]   Go Down
  Print  
Author Topic: Generating dynamic subdomains in apache  (Read 2990 times)
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #15 on: March 20, 2008, 10:54:22 PM »

Hello Omar,

Thank you for the detailed description. It is very helpful. Did check that inicio.php script does not use hard-coded value for the domain name to build up the URLs or incorrectly determines it?
Logged

Kind Regards,
Vlad Artamonov
odaier
Trekkie
**
Offline Offline

Posts: 12


« Reply #16 on: March 21, 2008, 10:00:23 AM »

Hi Perestrelka,

In fact, I dont know the exactly meaning of hard-coded value, but the value that is passed to the inicio.php is taken with a mod rewrite rule in .htaccess as following:


RewriteEngine On
# Extract the subdomain from the domain name
RewriteCond %{HTTP_HOST} ^([^.]+)\.webmemorial\.com\.br$ [NC]
# Verify that it's not the main domain, ie www
RewriteCond %1 !^www$ [NC]
# Then we are ready for the internal redirection

#to redirect to file in html directory /inicio.php with variable endinter
RewriteRule !^index.php$ http://www.webmemorial.com.br/inicio.php?endinter=%1 [L]

The endinter is the value that is passed to the DB to take all the others variables.

Did I understand your doubt?

Regads,

Omar

Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #17 on: March 21, 2008, 09:35:17 PM »

Omar,

How it works if you change the last rewrite rule to use the subdomain name. It can be something like:

RewriteRule !^index.php$ http://%.webmemorial.com.br/inicio.php?endinter=%1 [L]
Logged

Kind Regards,
Vlad Artamonov
odaier
Trekkie
**
Offline Offline

Posts: 12


« Reply #18 on: March 22, 2008, 02:44:40 PM »

Perestrelka,

I am so sory to did not see it before - I suppose that the first time that we use somethings we do know all the possibilities.
Your sugestion is very, very simple and make all the difference.
But, although the logical is simple and fantastic, it did not work.
In the begining, I thinked that was a problem with my script. So, I created a new php script named test.php  with just two lines:

<?php

  $endinter = $_GET['endinter'];
 
  echo "Adress: ".$endinter."<br>";

?>

And modify the line in .htaccess as you suggest:

RewriteRule !^index.php$ http://%1.webmemorial.com.br/test.php?endinter=%1 [L]

But I have a problem in Firefox:
an error message:
"The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies."

And at  IE, it seems that it goes to an infinite loop.

Please, try it.

I will maintain this data in my site until you see it.

Regards,

Omar







Logged
odaier
Trekkie
**
Offline Offline

Posts: 12


« Reply #19 on: March 22, 2008, 02:57:44 PM »

Perestrelka,
In time:

I have tryed
RewriteRule !^index.php$ http://%1.webmemorial.com.br/test.php?endnter=%1 [R=301,L]

Using the R=301 to try to stop the loop, but it did not make effect.

Regards,

Omar
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #20 on: March 26, 2008, 02:28:45 AM »

Hello,

I'm sorry for long time without a reply. I'll give it a test in my local environment and get back to you shortly.

Logged

Kind Regards,
Vlad Artamonov
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #21 on: March 30, 2008, 01:56:18 AM »

Omar,

I apologize for muting during this week. It was pretty hectic. I created an environment similar to yours and the following rewrite rules worked fine for me:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.main\.domain\.tld$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule !^index.php$ init.php?id=%1 [L]

Please give it a try and let me know about the result.
« Last Edit: April 08, 2008, 08:34:21 PM by perestrelka » Logged

Kind Regards,
Vlad Artamonov
odaier
Trekkie
**
Offline Offline

Posts: 12


« Reply #22 on: April 08, 2008, 09:20:01 AM »

Perestrelka,
I donīt know why  I did not recive any advise that you have post your last message.
Sorry, but  only today I visit the forum and see it.

I will try the rewrite rules that you made this weed and post the results.

Sorry again about the delay.

Regards,
Omra
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #23 on: April 08, 2008, 08:33:46 PM »


Not a problem. Please advise about the result of your tests.
Logged

Kind Regards,
Vlad Artamonov
odaier
Trekkie
**
Offline Offline

Posts: 12


« Reply #24 on: April 13, 2008, 02:27:10 PM »

Perestrelka,

Thank you so much for the time that you spend trying to help me, but the behavior of my system with your last tip did not work as in the beginning .

I will let it be, because  I think that is not so important for the user.

As soon as I have my sytem translate into english, I will tell you.
Best regards,

Omar Daier
o.daier@gmail.com
Logged
perestrelka
Administrator
Jedi
*****
Offline Offline

Posts: 980



« Reply #25 on: April 15, 2008, 09:42:34 PM »

Hi,

I am sorry to hear this didn't work for you. I'll be happy to help with setup of translated to English system Wink
Logged

Kind Regards,
Vlad Artamonov
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM