Forum Moderators: phranque
For example:
www.MySite.com is the main site.
www.InboundURL1.com is redirected to www.mysite.com/url1
www.InboundURL2.com is redirected to www.mysite.com/url2
when someone clicks on www.InboundURL1.com the browser address bar shows www.mysite.com/url1.
What I'd like is for the address bar to CONTINUE to show www.InboundURL1.com.
I cannot figure out how to do this. Seems like .htaccess mod rewrite should do this. I'm a newbie. Any help would be greatly appreciated.
Thanks in advance.
... I have actual URLs that are redirected to the main site.
That's the problem right there. You want to internally rewrite the subdomains to the subdirectories, not externally redirect them.
These are two different functions, not to be confused. mod_rewrite can do either, and the syntax is different for each. As a simple example:
Redirect (incorrect function for this application):
RewriteCond $1 !^sd_
RewriteCond ${HTTP_HOST} !^www\.example\.com
RewriteCond ${HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) http://www.example.com/sd_%1/$1 [R=301,L]
RewriteCond $1 !^sd_
RewriteCond ${HTTP_HOST} !^www\.example\.com
RewriteCond ${HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /sd_%1/$1 [L]
In the second case, we are doing an internal rewrite only: We simply tell Apache that if a request for a subdomain other than www comes in, that it should change the internal filepath and fetch the requested resource from the "/sd_<subdomain_name>" subdirectory instead of the 'home' directory. The client is not informed, and so leaves the original address in its address bar.
Note the differences in the syntax of the two RewriteRules.
The first RewriteCond prevents an 'infinite' loop in both cases.
Jim
Thanks. I'm FAR from an expert in this stuff ... I'm an application's guy who can just barely spell Apache. So thank for the feedback. I will try what you suggest.
Also, when you say "that's the problem right there." I want to make sure I actually understand the problem. www.InboundURL1.com is sitting on another server somewhere, or just "parked" and pointed to www.MySite.com/url1. So that's OK ... right?
Part II then is what must happen on the www.MySite.com server ... which is what you showed in the second (correct) example.
Did I get that right?
Now, again, remember, I'm WAY IGNORANT here ... so ... is all I need in the .htaccess file in what you wrote above?
Thanks again,
Al
Dump the "parking" and "pointing" and all the external dependencies, as you won't be able to fix this problem on machine B if the problem is cause by machine A doing an external redirect to machine B -- The redirect is what changes the address bar, and once the redirect is performed by the client, it cannot be un-done.
Jim
Thank you for the help. Again, because I'm so new at this, I just want to make sure I've got it right.
Again, remember, these are shared servers. So even www.mysite.com is being somehow magically sent to rs#*$!.hostingcompanyserver.com/~mysite/public_html/
In the case of www.InboundURL1.com (currently a "parked" domain), I want to change the DNS server name from whatever it is now to the SAME DNS as from wherever it is set now to the SAME DNS as www.mysite.com (from the first example). That happens to be ns1.securehostserver.com.
THEN I want to put the .htaccess code from your example in the public_html directory of www.mysite.com.
THEN when I type www.InboundURL1.com in my browser it will go to www.mysite.com/url1, but the browser's address bar will continue to read www.InboundURL1.com.
Have I got that correct so far?
If YES {
New question:
The index.php file in www.mysite.com/url1 redirects to www.mysite.com/x/y/index.php?S=zzz. The parm S=zzz MUST be set the first time a user starts a new session in order for the application to work properly (That's how the application knows that it's working on www.InboundURL1.com and not the native www.mysite.com).
Now, the browser should read:
http://www.InboundURL1.com/x/y/progname.php?S=zzzz.
Then I click any link on the home page (e.g., the link reads something like:
http://www.InboundURL1.com/x/y/progname2.php?NewParm=#*$!
I don't need the S=zzz any more. Apache will recognize this and just mod/rewrite www.InboundURL1.com INTERNALLY to www.mysite.com and leave www.InboundURL1.com in the browser address bar. Correct?
Now ... it's gets a little more complicated ... if someone bookmarks http://www.InboundURL1.com/x/y/progname2.php?NewParm=#*$!, and comes in the next day looking for that page ... they won't find it because S=zzz was not set!
One possible option is to append S=zzz to every page, but then I need .htaccess to know whether S=ZZZ should be preceded by a? (if its the only parm) or & (if there are parms before it). Can I do this too?
A second possible option requires a mod to the application which ALWAYS appends S=zzz to the end of any link in the application (a fair amount of work which I would like to avoid).
}else{
Thanks for your time but I'm hopelessly over my head, and will probably have to hire someone to fix this for me. LOL.
}
Again, thank you for your help, and I apologize for asking, what I am certain, are very basic questions. I promise not use up more of your time here. If I can't figure it out, I really will just hire someone to fix the problem ... or invest in dedicated servers.
I appreciate your help.
If not, you'll need to set up your server to "accept" the requests for the second domain name; With IP-based virtual hosting, you just point the new domain to the IP address of the server. With name-based virtual hosting, the server has to know the 'name' --the domain-- in order to pass the requests into your ~user filespace.
How you do this depends on your hosting service's standard procedures, whether you use a "control panel," and several other factors.
The business with the missing "S=zzz" parameter sounds like a rather fatal flaw with the design of the site -- Whatever requires that parameter should be re-designed and re-coded to either accept it being blank, or to fill it in if missing; Broken-by-design bookmarks and links will affect your search engine ranking, your traffic, your visitor loyalty, your revenue, or all of these.
Try a few searches [google.com] here for information on the difference between an internal rewrite and an external redirect -- I think you might find the answer enlightening and helpful with your project, but I don't have time to re-type it all right now. It sounds like you've got them mixed-up and that's partly responsible for your trouble.
Also, consider using static URLs for your site [webmasterworld.com], instead of passing all those query parameters -- Sites using static-looking URLs generally do better in the search results.
Again, short of time, I'd counsel you to hold off on changing the DNS or server configuration until you get the basic problem with the script fixed. Combined, these problems may seem insurmountable, but taken one-by-one and step-by-step, they're not so bad. They're also much easier to discuss in a forum that way, too... :)
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
In answer to the S=zzz issue: If the S parm is left off, it defaults to the main site with the main menu - so no problem. Also, if I can keep the inboundURL1.com URL in the browser, or I can make sure that inboundURL1.com actually goes to mydomain.com/inboundURL then I have no problem, so that's not really the core issue. The core issue is keeping the inboundURL.com domain name in the browser window.
On the issue of search engine optimization. As I mentioned I know nothing about Apache, but I've been building application software for more than 30 years and web applications since 1995. It is a fallacy that "normal appearing" URLs receive higher rankings that URLs with parameters. The "old wives tale" dates back to the early days of Google when they and Yahoo totally ignored anything after the "?" based on the "logic" that a? meant that the page content would change! Duh! Exactly. The rise of CMS, especially apps like Joomla, Mambo and the old phpNuke saw to it that "dynamic content" became part of the mainstream. I run over 100 sites. I have empirical evidence that parms on the URL vs. "normal looking" URLS makes absolutely, statistically, zero difference. Frankly, app designers waste a LOT of time worrying about, designing around that.
One last note ... example.com ranks between #3 and #5 when searching on "widget management" "widgets" with over 1 million results to the search, in Google. That's what it's optimized for. It's been in that range from week 3 post-site-launch. It's all parameter driven. Not a single "normal" url on the site.
On the IP address issue, I can have either a static IP address or not. I'm even considering just going completely away from shared servers and consolidating all of my domains on just two or three big dedicated servers, giving larger clients their own server.
That would solve everything because the server shell program has all kinds of "fill in the blank" manipulations you can do with masking URLs.
I gather, from what you've said, that if I have a static IP address the problem is much simpler. That's easy to do.
[edited by: jdMorgan at 3:09 am (utc) on May 1, 2007]
[edit reason] Example.com and widgets, please. [/edit]
From www.entireweb.com/about/search_tech/speedyspider/ :
Will Speedy download dynamic pages?Yes, but since dynamic pages are often database-driven, we limit the number of dynamic pages we download from a particular location during a crawl.
Again, keeping the requested URL is a matter of avoiding any redirects or meta-refreshes between the cleint request and server content delivery. If a domain is "parked" or "pointed" by some service not your host, then the problem will have to be addressed at that service; Once a redirect is done, it can't be un-done.
Jim