Forum Moderators: phranque
I have a question that I hope is just baffling me cause my regex skills are weak and not cause it's not possible.
I have a domain (www.randomdomain.com) that I direct to a dynamically created link on another site of mine (www.maindomain.com/index.php/landing-page) but I want the address bar to retain www.randomdomain.com in order to build an additional brand around randomdomain.com and for SEO stuffs relating to that brand.
Right now I have a basic rewrite
RewriteCond %{HTTP_HOST} ^randomdomain.com$ [OR,NC]
RewriteCond %{HTTP_HOST} ^www.randomdomain.com$ [NC]
RewriteRule ^.*$ "http\:\/\/maindomain\.com\/index\.php\/landing\-page" [R=301,L]
from other posts I've read on here, I'm gathering that this isn't the best solution anyway, but I'm trying to get this to redirect but keep the location bar as randomdomain.com.
I read over the intro to mod_rewrite post and have tried to search through the forum here, but am not able to piece anything together. Anyhelp would be much appreciated.
btw this is in my .htaccess file in the root of my site. Again, thanks,
Al
Once the randomdomain requests are routed to your maindomain server, you can probably use mod_rewrite to 'sort out' the two domains and handle them as you like. I say "probably" only because there will be limitations to the "add-on domain" approach that may get in your way, and it's more complex. If this is the case, then consider paying the small fee (usually around $1.00 a month) to upgrade from a shared name-based server to an IP-based virtual server.
Once you've got the above steps in place, you can take down the old server (and cancel that account), as it won't be reachable any longer.
Jim
I am paying for the unique IP you mentioned, and I am fairly certain the DNS for randomdomain.com points to the root of maindomain.com, and to my chagrin this was the solution I came up with for sorting it out :/
It appears as though I am approaching this from the wrong angle. Which angle will give me a bit more success? (I'm not asking for free code (though I'd gratefully accept it) I just can't quite figure out which mod_rewrite syntax to apply my headaches too. Thanks again for the response
If your intent is to "make the same content appear on two different domains without changing the address bar," then we have a single-word synonym for that here in SEO-land: Suicide -- or the less-dramatic two-word phrase, "duplicate content" (much-covered here at WebmasterWorld and findable using the site search feature linked at the top of this page).
However, if that's the goal, and both domains already resolve to the same directory on the same server, then you might have better luck with
RewriteCond %{HTTP_HOST} ^(www\.)?randomdomain\.com [NC]
RewriteCond $1 !^index\.php/landing-page
RewriteRule ^(.*)$ index.php/landing-page [L]
That might not sound wrong at first mention, but how about requests for images? Or for /robots.txt, /sitemap.xml, /labels.rdf, or /w3c/p3p.xml -- all "well-known," standard-name-and-location files? I doubt that you want to rewrite requests for those to your landing page! It would likely be better to "narrow down" the number and types of potentially-requested URLs that you plan to rewrite to that page.
BTW, the additional RewriteCond in the code above is intended to prevent an infinite rewriting loop.
Do consider the dupe-content and rewriting-scope caveats above; I suspect a rush to implementation before the actual requirements and effects have been studied.
Jim
Thanks for the thought put into the response. In searching for a solution to what I was trying to do already I came across another guy who was given similar caution about the duplicate content. I'll try and find it again, but essentially the idea is to either force any link that goes specifically to the maindomain.com/landing-page (users bookmarks, or other people's links) to the randomdomain.com site, is that a correct strategy?
I'll try out the changes and be back singing your praises tonight when traffic slows down.
Thanks Jim!
Al
That's a different problem then, and not one addressed by the code I posted above. But let's nail down one thing here: Is it that you want to have two different Web sites 'supported' by the same "index.php" script, but serving different content? If so, that is not a duplicate-content problem, but rather just a question of sharing infrastructure between two different sites. Two sites, one server, one (shared) script...
So is that the case here?
Jim
Is this maybe a 'leftover' --an artifact-- from a time before you decided to 'split' off some content into the newly-registered 'randomdomain.com'?
And is it the case that requests for maindomain.com and randomdomain.com now work normally and as required, but that you've got this artifact left over (dangling below maindomain.com, as it were) that you want to get rid of?
The problem with code is that you have to tell it exactly what you want to do... Because it will do exactly what you tell it to do... and not necessarily what you really want... :o
Jim
I have a web store on maindomain.com with a specific product located at maindomain.com/landing-page and I have built a brand around this product, registered the domain (randomdomain.com) which relates specifically to this product and which I use heavily in marketing and the like. I like the fact that the resources are shared, cause it works akin to a loss leader, where once it's added to the cart, people shop the rest of the other site, and it's a relationship that is working very well. But now I'm here with a redirect that is doing little for me in search queries and the like, and I can't use the randomdomain.com for anything more (It's around a single product, but I would like to put up a few more pages and options) not to mention maindomain.com/index.php/landing-page/ is much harder to remember or read off your bookmark than randomdomain.com. So that's what I'm trying to do right now. Does that make sense?
So, as far as the Web is concerned, the URL is randomdomain.com/, but the filepath (not seen by the client browser, but used inside the server) is /index.php/landing-page
Notice the distinction between the URL used 'out on the Web' and the filepath used inside the server -- That's really the key to understanding this and many other URL-rewriting problems. URLs and filepaths are not at all the same thing -- or even related; They are only 'associated' by the action of a server.
If the above functional description is correct, you'll need:
# Externally redirect direct client requests for /index.php/landing-page to randomdomain.com/
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php/landing-page\ HTTP/
RewriteRule ^index\.php/landing-page http://randomdomain.com/ [R=301,L]
#
# Internally rewrite requests for randomdomain.com/ to /index.php/landing-page
RewriteCond %{HTTP_HOST} ^randomdomain\.com [NC]
RewriteRule ^$ index.php/landing-page [L]
Jim
Thanks! and I'm googling canonicalization now, I'll see first if I can figure out what that means, and second how I need to fix it on my site :-)
This includes casing errors, FQDN-format hostname requests, port numbers appended to the hostname, page name variations and query string variations. The idea being that search engines don't consider "files" or "pages" or anything else; The only 'objects' they consider are URLs.
Therefore, if you have more than one URL for a 'page,' then those two (or more) URLs 'compete' with each other for search rankings, and so your own pages compete with themselves, with neither doing as well as it would on its own. Some who delight in making SEO seem dangerous and mysterious refer to this as a "duplicate-content penalty," although it's actually more like self-inflicted injury; Actual search engine penalties may indeed exist for this, but if they do, they're reserved for the most egregious and intentional cases, IMO.
Consider that on a site where no steps are taken to prevent it, the following URLs may all be used to directly access the home page:
example.com/
example.com/index.html
example.com./
example.com./index.html
example.com:80/
example.com:80/index.html
example.com.:80/
example.com.:80/index.html
example.com/
example.com/index.html
example.com/?any-bogus-query-string
www.example.com./
www.example.com./index.html
www.example.com:80/
www.example.com:80/index.html
www.example.com.:80/
www.example.com.:80/index.html
www.example.com/?any-bogus-query-string
That represents a potential 14-to-one dilution of the 'ranking power' of this page, just counting those shown here. And not all variations have been shown in the interest of brevity... For example, the query string could be appended to all of the other variations as well, and the number of possible different query strings is large enough to be considered 'infinite'.
So "canonicalization" as we use it here simply means cleaning up this mess to prevent accidental or malicious dilution of page ranking.
Jim