Welcome to WebmasterWorld Guest from 54.162.117.84

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 whole subfolder to single url

     
7:07 pm on May 7, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 10, 2005
posts:36
votes: 0


Hi All. I am looking for a way to do something, but I have no knowledge of redirects and have nothing much on my .htaccess file as of yet.
I had a blog located in this directory:
/blog (no trailing slash)

the pages that were a part of my blog were in this format, with a trailing slash at the end of the full url
http://www.example.com/blog/social-networking-cards/

this is what I added to my .htaccess so far:

<Files .htaccess>
order allow,deny
deny from all
</Files>
redirect 301 /blog http://www.example.com/free-graphic.htm

Since the blog no longer exists, I left the blog/ folder and an index.php inside of it, but want to delete it altogether.
I was trying to re-direct all blog traffic to one single page
www.example.com/free-graphic.htm

The snip I have above works fine for all traffic coming from the home page of my old blog to the page specified above, but when a request comes for a specific post page,
it appends part of that old post page onto the redirected url, like so:
www.example.com/free-graphic.htm/social-networking-cards/

Is there any way I can just get the /blog folder and old indexed posts to redirect to that one page if people arrive by an old indexed post url?
In other words, I hope to have any page requested from old /blog, end up on this specific page:
http://www.example.com/free-graphic.htm

I should mention that I am not very knowledgeable with .htaccess, just know enough to follow instructions.

I would greatly appreciate any advice given. Thanks!

[edited by: jdMorgan at 3:38 pm (utc) on May 9, 2008]
[edit reason] Please use example.com. [/edit]

7:28 pm on May 7, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Yes, that is what Redirect does.

It takes all of the stuff found after whatever you specified on the left, and appends it on the end of whatever you specified on the right.

For what you want to do, you'll need RewriteRule instead. There's plenty of prior examples here. Grab one, modify it, see how you get on, and then post your best effort back here.

10:15 pm on May 7, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Or you can use mod_alias' RedirectMatch directive.

Jim

2:52 am on May 8, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 10, 2005
posts:36
votes: 0


I didn't have too much confidence in figuring it out on my own, but I think I have it.

I took the example:
RedirectMatch page1\.html page2.html

from the library:
[webmasterworld.com...]

and changed it like this:
RedirectMatch /blog\.php /free-graphic.htm

and it now works!

Response Headers

Date: Thu, 08 May 2008 02:40:52 GMT
Server: Apache
Last-Modified: Sun, 04 May 2008 08:54:56 GMT
Etag: "33003e-2486-481d79e0"
Accept-Ranges: bytes
Content-Length: 9350
Content-Type: text/html

200 OK

Made my changes and I changed the .html part to .php because that is what my blog used, hopefully I did that correctly, but it is acting like I wanted with no error, thanks a heap to both of you!

6:37 pm on May 8, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


What happens when you request the www version of the old URL and the non-www version of the old URL.

Do you get to the www version of the new URL, in just one hop, or does it take multiple hops? Multiple hops can be bad news.

9:03 am on May 9, 2008 (gmt 0)

New User

10+ Year Member

joined:Jan 10, 2005
posts:36
votes: 0


Thank you g1smd

One hop :D

9:11 am on May 9, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Good stuff.

It can be difficult to avoid a redirection chain but it is well worth taking the time to do so.