.htaccess redirect when domain name is unknown - apache

I have a site that I am not sure what the domain name will eventually be when it's live, but as I am working on it I access it through a local server. One of the directories on the site needs to be redirected. To save time when the site goes live (and also just to learn how) I am trying to write a .htaccess statement that will redirect the directory regardless of what the domain name is. Currently I access the site through:
http://phuk9220/
I want this directory:
/audio/help-and-faqs/
to redirect to:
/audio/help-and-faqs/welcome/
Now, I can easily do this with:
RedirectMatch 301 ^/audio/help-and-faqs/$ http://phuk9220/audio/help-and-faqs/welcome/
However, it means changing the http://phuk9220/ to whatever domain will it will eventually be on. Is there anyway of changing the domain dynamically depending on where it actually is ?
Thanks in advance and if you have any questions, please ask.
Alex

Simply omitting the domain name entirely should do the redirect on the same domain that was requested.
RedirectMatch 301 ^/audio/help-and-faqs/$ /audio/help-and-faqs/welcome/

Related

.htaccess rewrite domain but keep directory structure and preserve url in address bar

I have copied a Joomla site from one domain to a new domain.
I want to rewrite the domain name only to keep the directory structure.
And I want to keep the original URL in the address bar to preserve SEO ranking.
Joomla is using relative url's, so the real domain name of the new server will not as such be invoked by Joomla.
How to do this in .htaccess on Apache?
And I want to keep the original URL in the address bar to preserve SEO ranking.
That won't help you really, just add proper 301 redirects and make sure you catch as much of the indexed url's with your redirects component within joomla to prevent any dead links (google hates those and will penalize your domain for it). Also add sitemap, upload it to your google webmaster tools and ask google to index it.

Redirect Rewrite for Joomla Root Domain Only?

I recently migrated an existing site between two domain names. I created 301 rewrite rules for all existing pages to their new, corresponding links and that appears to be functioning correctly.
Since I individually mapped the link rewrites I didn't have the need to apply a broad redirect all visitors. The issue I am experiencing is that I have not been able to successfully 301 redirect the root (home/index) only. I have tried redirecting / as well as /index.php, but those rules appear to interfere with my other rewrite rules. I'm guessing this has something to do with Joomla's core SEF rewrite rules, but I'm not sure.
Example:
Let's assume this is one of my redirects:
Redirect 301 /oldlink http://www.example.net/newlink
But someone somehow visits /oldlink25 (which doesn't exist and never has). The current setup where I am redirecting /index.php, which is my attempt to redirect the root only, will still redirect this visitor to the new site root. I'd prefer to 404 that visitor, and the old link, at the old domain instead.
Long story short, unless someone visits a link that has an individually declared 301 in the htaccess, how can I redirect visitors that hit the root only and not every visitor that hits any random link without a corresponding rewrite rule?

Redirecting from example.com to www.example.com

My site uses AJAX, and it seems like I have to include the full path when I use it to access a function. This is fine, as I can code it in. The problem is, I have hardcoded http://www.example.com... but if a user has gone to http://example.com (without the www) this gives an access problem and the AJAX won't execute.
I think the easiest way to resolve this would be to make sure that if a user goes to mysite.com, they are redirected to www.example.com.
I can find solutions online, but they all involve the htaccess file, which my server doesn't support - I have to use rewrite.script instead.
How can I do this using rewrite.script, or is there an alternative way to approach this?
Thanks for the suggestions - I was directed to this: http://seo-website-designer.com/Zeus-Server-301-Redirect-Generator which created the rewrite.script file I needed.
In .htaccess found in your root document:
Redirect http://example.com/ http://www.example.com/
If there is no support for .htaccess on your server, you may have to include meta tag redirect on the head of your page. or using javascript to check the URL source then redirect it.

Multiple Domain name

I have a customer that been on the web for some time. They have bought a domain name that describe it product, and a second one more up to date. Now that company has evolved to something more general and has bought a 3rd domain - something like:
vegetables.com (2005)
ecolo-vegetables.com (2006)
good-health-eating.com (2009)
Here are my questions:
What is the bet way to get all those domains under the new name?
The new name is unknown to search engine and other linker, I don't want to lose the ranking, so what is the best way to keep that ranking?
Can I point URLs to the "best" ranked domain?
What append to the backlinker? they link to which domain?
The new domain has a "-" in the name... which is really good to SEO but a little unnatural to type, should I get the no dash version too?
n.b. It make sense to redirect all the domain under the same, but will you choose the oldest (with modrewrite) or the newest but with no life under it's belt (so it doesn't exist anywhere in search engine)
another p.s. Some will tell me to redirect with .htaccess, but should I change the dns to point to the last .com. which solution is better
Are all three sites "Different" or do they point to the same website/content?
Use 301 Redirects to redirect your old domain names to the new domain names. If all domains are pointing to the same website, make sure you also use the Canonical Tag on all your pages.
If you 301 Redirect from the old domain names / urls, your rankings will be transfered to your new domain/pages. (the only exception to this may be any extra points you get from embedded keywords in your old domain names).
You should point old urls to your "new" urls/domain. Rankings and link juice should/will be transfered to the new urls/domain.
Ideally all your backlinks should update their links to the new domain, but it doesn't really matter. If the old domains are 301 redirecting to the new domain anyway, point to the old domain is just like pointing to the new domain.
Definitely get the no-dash version of the domain as well and just have it 301 redirect to the actual domain you want to target.
I'll give this a go.
1. You could possibly have redirects or just allow the DNS of the domain to point to the new (desired) website.
2. It's not hard to understand SEO (Search Engine Optimization) nowadays - ensuring you have the correct meta tags and other SE info will give you a big helping hand. There isn't any way of transferring SE ranks.
3. That's possible. You could have ABCDEF.COM at number 3 on google, but then set ABCDEF.COM to redirect to GHIJKL.COM.
4. If you set up redirects, and the new site has the same content as the old one, there is the possiblity of setting up your DNS and your redirect to redirect to the new version of the previous page on the new website.
( I don't think I worded that very well, hope you catch my drift )
5. Out of pure experience I'd say yes, get both. That way you can market to your customer audience as ABCDEF.com, but show to SEs as AB-CD-EF.COM.
Here is the best answer i got from this link
302 and 301 Redirects
When a request for a page or URL is
made by a browser, agent or spider,
the web server where the page is
hosted checks a file called
'.htaccess'. This file contains
instructions on how to handle specific
requests and also plays a key role in
security. The '.htaccess' file can be
modified so that it instructs
browsers, agents or spiders that the
page has either temporarily moved (302
redirect) or permanently moved (301
redirect). It is usually possible to
implement this redirect without
messing with the '.htaccess' file
directly, using your web host's
control panel instead.
From a search engine perspective, 301
redirects are the only acceptable way
to redirect URLs. In the case of
moved pages, search engines will index
only the new URL, but will transfer
link popularity from the old URL to
the new one so that search engine
rankings are not affected. The same
behavior occurs when additional
domains are set to point to the main
domain through a 301 redirect.
And the last word : from this link that just confirm what i know know !
First off, ensure you're using "301 redirects" rather than "302 redirects" or the link juice (PageRank) won't transfer to the destination URL. You can verify that 301s (not 302s) are in place by using a "server header checker" like this one. Only a 301 tells engines the previous URL has moved permanently and thus forwards the page's link equity to the new location.

Why are two authentication cookies being created? One for www and the other without the www

I'm having this problem with my dotnetnuke website where the .DOTNETNUKE cookie is being created twice,
one for www.website.com and one for website.com.
When a user logins in with a url of website.com and tries to access a page that is www.website.com it causes them to re-loggin with a new cookie for www.website.com. This results in two cookies, one for www.website.com and another for website.com.
How do I fix this, does anyone have any ideas where to start?
Thanks!
John
This has to do with the dot rule. One of the security checks that a browser does is makes sure that a cookie's domain has the same number of periods as the domain it's on. A cookie from www.example.com will have the domain, "www.example.com" or "*.example.com", where as a cookie from "example.com" will have the domain "example.com". So the browser's thinking "example.com isn't/may not be the same as www.example.com, better get a new cookie just in case."
Set up your server so that it redirects your users to either www or no-www. Make sure you choose one or the other and stick with it. Having two will not only cause your current cookie woes, but possibly hurt your page rank in search engines.
See here for more info:
A question on SO relating
Dot rule stuff
To avoid IIS configuration I found a url rewriting tool here http://urlrewriting.net/149/en/home.html. It works like a charm!