Redirect and .htaccess not clear to me


#1

As will become clear, I am not an experienced Apache user.

I had a video blog, http://hestakaup.com on TypePad. It worked well, but the software was limiting.

I developed a joomla site on http://shirson.com/joomla on DH so I
could learn Joomla and work out some problems with video pop-ups.

Once I got everything set, I wanted to use the domain hestakaup.com on
DH with Joomla. After a lot of grief, I managed, through the forum,
to get hestakaup.com running on DH.

There is now no problem at all with the DH domain http://hestakaup.com

BUT as many times as I have tried to redirect
http://shirson.com/joomla to http://hestakaup.com it does not work. I tried everything I could through the DH Panel.

You can type http://shirson.com/joomla and that is what you will get.
I want it so that when you type http://shirson.com/joomla it will take
you to http://hestakaup.com

I don’t know how to make this any clearer.

I now think it may be a problem with .htaccess somewhere or something I do
not understand about the DH Panel.

I got a response from DH Support:

Now this is all well and good, but I do not believe I am redirecting filenames and I do not know that I want to limit the redirect to a filename in case someone types in a more complex link referring to specific Joomla content. There are, in fact, links to shirson.com/joomla content. (I don’t know whether they are files in the mySql database.) For example, a popular link is:
http://www.shirson.com/joomla/index.php?option=com_content&task=view&id=13&Itemid=35

I want this to be redirected to http://www.hestakaup.com/index.php?option=com_content&task=view&id=13&Itemid=35

In some Googling, I came up with variants on

RedirectMatch permanent ^/$ www.mainsite.com/folder

As you can see, this is clearly not the DH wiki recommends.

And, if I do add this to my .htaccess file, which one do I put it in? The one in shirson.com/joomla? Just that? Do I leave all the other stuff in?

Confused!

Sorry that this is so long, but as it is a public forum I hope that some information can be shared with other newbies like myself.

shirson


#2

[quote]For example, a popular link is:

I want this to be redirected to http://www.hestakaup.com/index.php?option=com_content&task=view&id=13&Itemid=35[/quote]
This excerpt (from an excellent resource on using .htaccess, published by Earthlink/Mindspring, should point you in the right direction:

[quote]

Redirect

Syntax: Redirect [ status ] url-path url

The status argument is only available in Apache 1.2 or later.

The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. Url-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) url beginning with url.
Example:

Redirect /service http://foo2.bar.com/service

If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.

Note: Redirect directives take precedence over Alias and ScriptAlias directives, irrespective of their ordering in the configuration file. Also, Url-path must be an absolute path, not a relative path, even when used with .htaccess files or inside of sections.

permanent
Returns a permanent redirect status (301) indicating that the resource has moved permanently.

temp
Returns a temporary redirect status (302). This is the default.

seeother
Returns a “See Other” status (303) indicating that the resource has been replaced.

gone
Returns a “Gone” status (410) indicating that the resource has been permanently removed. When this status is used the url argument should be omitted.

Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the url argument must be present, otherwise it must be omitted. Note that the status must be known to the Apache code (see the function send_error_response in http_protocol.c).

RedirectTemp

Syntax: RedirectTemp url-path url

This directive makes the client know that the Redirect is only temporary. (Status 302). Exactly equivalent to Redirect temporary

RedirectPermanent

Syntax: RedirectPermanent url-path url
Context: directory, .htaccess

This directive makes the client know that the Redirect is permanent. (Status 301). Exactly equivalent to Redirect permanent [/quote]
Translating the above to your situation:

RedirectPermanent /joomla http://hestakaup.com

when placed in an .htaccess file located in the “base” directory of shirson.com (the directory within which the “joomla” directory resides), will cause the following to take place:

If the client requests http://www.shirson.com/joomla/index.php?option=com_content&task=view&id=13&Itemid=35 , it will be told to access http://www.hestakaup.com/index.php?option=com_content&task=view&id=13&Itemid=35

Which is what I believe you want to do.

Place it in the “top” web accessible directory of shirson.dom (on Dreamhost, the directory is probably named “shirson.com”). As .htaccess files impact all directories below them in the directory tree, that is all that is needed to impact the “joomla” subdirectory of shirson.com. Once this is done, there is no need to leave anything in the joomla sub-directory (that means files, and other directories). Test it first to make sure it is working as expected, then you delete all the other stuff.

This method works particularly well in your situation, because you should not experience any google penalty for doing it this way, and users that have existing links won’t be left “stranded”. Additionally, this allows you to go ahead and further develop shirson.com with freedom (just make sure and leave that line in whatever .htaccess file you ultimately end up using in the shirson.com directory. Good Luck, and let us know how it all works out. :slight_smile:

rlparker


#3

Just create a file names index.php with this one line

<?php header('Location: http://hestakaup.com'); ?>

and place it here

Then http://shirson.com/joomla will redirect to http://hestakaup.com very quickly


http://theMezz.com


#4

That’s a good “quick” way to redirect to the main page of his new site, but will it preserve the routing for urls that point to specific content? :wink:

–rlparker


#5

No but just also ass a missing.html file


http://theMezz.com


#6

I understand. The reasons I suggested the RedirectPermanent .htaccess method were so that he could:

  1. Have urls that point to a specific piece of content be redirected to the desired content.

  2. To avoid potential penalty issues with Google and the types of redirects that are often used for “cloaking” or other “search engine gaming” schemes (such as when a webmaster uses “” from numerous domains that all point to the same content

  3. Avoid the overhead of spawning an additional process (php.cgi)

It’s not that your suggestion is not a good tool to have in your “bag of tricks”, and I’m glad you shared it; I just think he is better served in this instance using a .htaccess redirect (of course, YMMV and there are many ways to “skin this cat” :slight_smile: )

–rlparker


#7

I agree
My method is easier and it works.
I am not sure if it’s better
:slight_smile:


http://theMezz.com


#8

Worked like a charm!

I put in the .htaccess and had to leave for a few hours and found from my stats that the various urls came through perfectly.

I took rlparker’s advice

[quote] RedirectPermanent /joomla http://hestakaup.com

When placed in an .htaccess file located in the “base” directory of shirson.com (the directory within which the “joomla” directory resides), the following will cause the following to take place:

If the client requests http://www.shirson.com/joomla/index.php?option=com_content&task=view&id=13&Itemid=35 , it will be told to access http://www.hestakaup.com/index.php?option=com_content&task=view&id=13&Itemid=35 [/quote]
They all came through fine!

Very neat solution. So far, so good!

Thanks, all for your help.

shirson


#9

I noticed that the www version of your site is a PR 3 and the non-www version is PR 1. If you care about Google PR, two more easy little things you might want to do:

  1. Add the www to that line, making it redirect to http://www.hestakaup.com, instead of http://hestakaup.com.

  2. In the panel, choose to add the www even if it’s not typed in.

The 301 redirect will pass the PR to the www version and won’t be affected if people link to you without the www.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#10

Mike,

Those are really nice tips! I tell you, it’s a “trick a minute” to try to stay where you want with google! Of course, if you pay any attention to the guys at no-www.org, they would probably suggest just waiting till the “no-www” catches up in page rank. :wink:

It would be interesting to see if a concerted effort to always become linked without the “www” would eventually garner the same, if not higher, page rank for the “no-www” address as that enjoyed by the “www” one…I suspect that the “old habits die hard” rule is likely to come into play though, as others will probably still include the “www” when linking to you no matter what your efforts are to get them to do otherwise :open_mouth:

At any rate, thanks again for the good tips!

–rlparker


#11

And I made the changes and everything seems to be working fine!

I’m thrilled!

Thanks a lot, guys.l

shirson


#12

You can throw it either way and Google won’t care about whether there’s a www or not… but if one already has more PR, I usually just go with that version, since that’s where most of the links seem to be pointing.

I have sites that redirect both ways, so I’m not fanatical about either version.

I usually go with www for business sites, or sites that advertise offline, because I think the www screams “Website!” to the average person. Example:

www.SomeBusinessName.com
SomeBusinessName.com

In that case, you instantly read it as a website, rather than a business name. The second one will seem like a business name until you hit .com at the end. Personally, I’ve noticed that with T-shirts, a www. catches my eye.

Another advantage in the offline example is that the www gives the name more of a centered look. That can come in handy for business card/letterhead layouts, etc…


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#13

All very good observations, and I agree. I think to some degree, the no-www types are kinda like those that get crazed if you end a sentence with a preposition :wink: .

–rlparker


#14

One more thing!

Everything is working so well I don’t want to “fix” it! But my Google Analytics stats are being taken from the old url, shirson.com/joomla and very rarely from hestakaup.com which is what I want it to be using. I should close down shirson.com/joomla and I wonder if I can do it just by renaming the folder, shirson.com/joomla/joomla something else. That way, I can easily restore it by renaming it. In the event that it all works, then I would delete the folder.

I want to point out that one of the confusing things about working on this system is that I don’t see the applications program in the hierarchy. So I can’t just rename a joomla.exe joomla.old the way I could on a PC.

Am I understanding this? I would like some confirmation before I pull the plug!

Thanks for all,

shirson


#15

Stan,

Renaming the directory (“folder”) is fine, though I see no reason at all to even maintain the .old directory (it was there as a “backup” in case your upgrade failed, from weeks ago, and it didn’t :wink: ).

Once you have assured yourself that everything still works after the rename, you can delete the directory; all your “Joomla! stuff” is on hestakaup.com.

You generally won’t see “.exe” files here, as your “application” is the collection of files that are part of the Joomla! installation. Deleting the directories’ contents, and the directories, deletes the “application.”

One last suggestion I have for you though: If you don’t want visitors to shirson.com to be able to browse the directories containing your videos, images, and tools, you need to disable directory listing for that directory (you can search the wiki for that) or, as is more commonly done, put an index.html (or index.php, etc.) file in your “shirson.com” directory as described in this Dreamhost Wiki Article on Getting Started.

–rlparker