homepage Welcome to WebmasterWorld Guest from 54.227.34.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 whole subfolder to single url
shyspinner

5+ Year Member



 
Msg#: 3644143 posted 7:07 pm on May 7, 2008 (gmt 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]

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3644143 posted 7:28 pm on May 7, 2008 (gmt 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.

jdMorgan

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



 
Msg#: 3644143 posted 10:15 pm on May 7, 2008 (gmt 0)

Or you can use mod_alias' RedirectMatch directive.

Jim

shyspinner

5+ Year Member



 
Msg#: 3644143 posted 2:52 am on May 8, 2008 (gmt 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!

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3644143 posted 6:37 pm on May 8, 2008 (gmt 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.

shyspinner

5+ Year Member



 
Msg#: 3644143 posted 9:03 am on May 9, 2008 (gmt 0)

Thank you g1smd

One hop :D

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3644143 posted 9:11 am on May 9, 2008 (gmt 0)

Good stuff.

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved