homepage Welcome to WebmasterWorld Guest from 54.227.160.102
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

    
.htaccess 301 redirect problem?
Mandala72

5+ Year Member



 
Msg#: 4030796 posted 12:10 pm on Nov 24, 2009 (gmt 0)

Hi there

I've been spending hours trying to implememt a 301 redirect for 3 of my old pages. I realised they had gaps in their titles, so put up new pages without gaps and need the old pages to redirect to the new.

I have uploaded a .htaccess file to the same folder my index file is in, with the following format of code:

Redirect 301 public_html/Widget Page.html [Mysite.co.uk...]

However the redirect is still not working. My host verified a 301 should work ok.

Does anyone have any tips where i could be going wrong?
Would the original gap be causing an issue?
Does the above code look correct?
Is there another code format i could choose?

Thanks for any assistance in this matter , im stumped...

 

jdMorgan

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



 
Msg#: 4030796 posted 2:18 pm on Nov 24, 2009 (gmt 0)

These "gaps" are spaces, which are required to be encoded by the HTTP/1.x protocols.

The "public_html" filepath is not likely to be part of the requested URL, since it is part of a server filepath (not part of a URL).

Therefore, the URL being requested in your example above is likely to be "example.com/Widget%20Page.html" and the URL-path just "/Widget%20Page.html"

I'd recommend that you try the two following variations using mod_alias RedirectMatch. If neither works, then it may be necessary to use a more-powerful module to solve the problem:

RedirectMatch 301 ^/Widget\%20Page\.html$ http://www.example.co.uk/Widgetpage.html

-or-

RedirectMatch 301 ^/Widget\ Page\.html$ http://www.example.co.uk/Widgetpage.html

Using either mod_alias RedirectMatch or mod_rewrite, both of which make use of regular-expressions pattern-matching, it may be possible to create one directive which redirects all three problematic URLs. However, since you gave only one example, it's not possible to tell at this point.

Jim

Mandala72

5+ Year Member



 
Msg#: 4030796 posted 12:16 pm on Nov 25, 2009 (gmt 0)

Cheers for the help JD, much appreciated.

i tried all the methods you suggested above but with no luck so far. I never realised a redirect could be so problematic.

As a temporary (maybe permanent?) solution, i have just reupped the old pages with the title gaps and will just leave them alongside the new pages. I have changed the text a little between pages so as not to cause any duplicate content issues.

Not the ideal solution i know

Cheers again
Pete

jdMorgan

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



 
Msg#: 4030796 posted 2:41 pm on Nov 25, 2009 (gmt 0)

Well, you could try mod_rewrite, which can access the HTTP Request line exactly as sent by the client (and exactly as logged in your raw server access log file). With the caveat that mod_rewrite is quite a bit more complicated that mod_alias -- and especially in cases like this, you could try something like:

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /Widget(\ ¦\%20)Page\.html\ HTTP/
RewriteRule ^Widget.+Page\.html$ http://www.example.co.uk/Widgetpage.html [R=301,L]

However, you must be sure to replace the broken pipe "" character in the RewriteCond with a solid pipe character before use; Posting on this forum modifies the pipe characters.

Jim

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