Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2013, 10:25 AM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,513
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Problem with an added "www" ??

Hi,

Not sure if this is a PHP problem.

I have set up a site which produces a webpage.

eg villarentfethiye.simpg.net

So an example page is:

Villa Rental

The page is converted to :

http://simpg.net/info.php?a=villarentfethiye

by the .htaccess file.

This is the code:
Code:
RewriteCond %{HTTP_HOST} ^(.+).simpg.net [NC]
RewriteCond %{HTTP_HOST} !=www.simpg.net [NC]
RewriteRule ^.*$ http://simpg.net/info.php?a=%1 [NC,QSA,L]
The problem is that some browsers apparently add a
"www" to the front of the url automatically.

So when they put "villarentfethiye.simpg.net" into the browser bar
it tries to find "www.villarentfethiye.simpg.net"

and then the system produces an error
saying it can not find the page because it is tryying to
locate: http://simpg.net/info.php?a=www.villarentfethiye
which does not exist

I am not sure of the best way to deal with this.

Some thoughts ... ?

Thanks.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-17-2013, 01:57 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Not a thing to do with PHP or your htaccess.
If the browser is prepending www on front of a subdomain, than that is an issue with the user's browser. All you can do with it is remove the www from the provided input.
If you are using subdomains though, you should actually set them up. Your control panel should have an option to do so. If they are not real subdomains, I can see that being a bit flaky. You'll need to modify the DNS records to use wildcarded domains as well if they are not yet set.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 01-18-2013, 06:16 PM   PM User | #3
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,513
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Thanks for your reply.

Quote:
If they are not real subdomains, I can see that being a bit flaky.
They are not real sub-domains because they are created when someone creates
a new set of pages. So there could be thousands of them.

I think that wordpress.com and blogger.com do the same thing and Google
suggested that Hubpages.com do it that way as wel when they complained
they had lost 50% of their traffic in the last update.

Maybe the above three do actually create real subdomains on their servers, but I
doubt it and I don't see the need when one line in the .htaccess file can deal with
the situation and get the data from the database table.

But do you think it could cause problems ?

Also :
Quote:
You'll need to modify the DNS records to use wildcarded domains as well
if they are not yet set.
Do I need to do this even if I do not have REAL sub-domains ?

I was thinking ...

I guess I can check to see if there is a "www." at the beginning of the GET data
and then strip it off before looking it up in the table ??

Thanks for any thoughts.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-18-2013, 06:44 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You would expect you need to set the wildcard domains. Otherwise, it will bind to site.com, and not to sub.site.com, so it won't actually route anywhere on the server. For these you'll need to contact someone proficient with DNS and webservers for the correct configurations.
I didn't think that www. was valid prepended to a subdomain, but I could be wrong. Assuming that its not valid, than the browser is to blame, and not the configurations (unless it can somehow interpret it differently based on the httpd host).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:00 PM.


Advertisement
Log in to turn off these ads.