Forum Moderators: phranque

Message Too Old, No Replies

301 redirect . Need Help to redirect from sub-folder to Root dir

         

jpservicez1

3:02 pm on Jul 26, 2008 (gmt 0)

10+ Year Member



I need help please.

I want to do a permanent redirect using htaccess from

example.com/subfoldername/

TO

example.com/

Thanks

g1smd

3:25 pm on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



All folders, or just one explicitly named folder?

From both www and non-www, or from just one? If so, which one?

Preserve the www or non-www origin, or redirect both to the canonical form?

Redirect when only the exact foldername is requested, or redirect for all files within the folder too?

Preserve filenames within the folder, or strip the filenames in the redirect?

Preserve query strings, or strip them?

jpservicez1

3:41 pm on Jul 26, 2008 (gmt 0)

10+ Year Member



g1smd

just one explicitly named folder

for both, www and non-www

can i have examples of [ Preserve filenames within the folder] **AND** [strip the filenames]

same as [Preserve query strings, or strip them?] can i have example of but..

ok the story is i created a mobile content pages from my main site pages in a sub folder.

main site = example.com/
mobile pages section = example.com/mobile/index.php

google has come back and slap me with duplicate penalty. It did find main site links on the mobile content section and i have fix those but i feel that if by using sub-folder its still a duplicate i will host in a different complete domain site. So i want to redirect the mobile page to the main site page.

Also can i ask a question..if on you main site you have content A. then you create a page just for mobile devices in a sub folder and place a modified content A but for just mobile devices. Is this still a duplicate.

jdMorgan

4:02 pm on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This sounds like you've got problems with the design and/or implementation of your mobile site. While you may want to use redirects to fix the problems in the current search index listings, I'd advise you to review the design of your mobile pages before trying to put a small band-aid on a major wound.

Note that while Yahoo and MSN use a subdomains for mobile pages, Google uses a subdirectory. Either approach should be fine, and not cause duplicate-content problems in itself.

Make sure your mobile pages are written in xhtml+xml, WML, or cHTML, and declare the proper DocType and encoding (usually UTF-8). Make sure that the Content-Type (MIME-type) headers returned with documents reflect those settings. Make sure the documents validate to the declared DOM and namespace in the DocType.

If you use a sitemap, be sure to declare <mobile:mobile /> in each <url> section of the sitemap.

Do not automatically redirect mobile devices based on the user-agent prefix only; Check to be sure it is not a search engine spider before doing this.

Finally, these mobile pages should be significantly smaller than the "normal" Web pages. The <title>, <description>, and on-page text should all be significantly shorter than those on your regular Web pages.

With all the above, you should not have any duplicate-content problems.

(Also, you have my sympathy -- I've gone through the "add a mobile section" process before, and the absolute lack of useful documentation for Webmasters is stunning.)

It is our procedure here to ask that you post your own code --your best effort-- to serve as a basis for discussion. This gives us a chance to avoid needless discussion of things you may already know. Please see our forum Charter for more info.

Thanks,
Jim

jpservicez1

3:22 am on Jul 27, 2008 (gmt 0)

10+ Year Member



jdMorgan,

Appreciate your comments and advise. For now i will put aside setting up mobile pages. I would rather focus on the main site.

Now regarding my original question...what code should i put in my htaccess to redirect a file in a sub folder to another file in the root directory. For example

sub folder - http://www.example.com/mobile/filename.php
need to redirect to another file in root directory - http://www.example.com/destinationfile.php.

Thanks
jpservicez

jdMorgan

2:45 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Take a look at the mod_rewrite documentation, and post your best-effort at a solution. Also please see our Forum Charter; Our goal here is to help you learn to write this code for yourself, as we cannot possibly support all the requests we'd get if this forum attempted to provide a "free code-writing service."

Thanks,
Jim

g1smd

5:24 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That said, there are many posts in even the last week that contain snippets of code that are very close to what you need.

Experiment on your dev server until it works, and post your best effort here if you can't get it to work as expected.

There's a world of learning to be had by installing Apache and PHP on a spare machine in your office and just experimenting.

jpservicez1

10:29 am on Jul 30, 2008 (gmt 0)

10+ Year Member



Thanks guys have manage to figure it out.