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

    
410 - gone in htaccess
410 a page with spaces in URL
joergnw10

5+ Year Member



 
Msg#: 3210546 posted 5:46 pm on Jan 6, 2007 (gmt 0)

I want to 410 a page in my htaccess that has spaces in the URL. I replaced the spaces with %20, but it always returns a 404.
Other 410's (no spaces in the URL) work fine.
What could be the problem?

 

jdMorgan

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



 
Msg#: 3210546 posted 9:29 pm on Jan 6, 2007 (gmt 0)

Please post an example of the code that doesn't work, with "example.com" as the domain.

Thanks,
Jim

joergnw10

5+ Year Member



 
Msg#: 3210546 posted 10:06 pm on Jan 6, 2007 (gmt 0)

Hi Jim, here is the main part of the htacess plus the redirect that won't work. Thanks for your help!

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.(.*)
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
RewriteEngine on
RewriteRule ^Folder%20with%20three%20spaces/page.htm$ - [G]

I tried it with the %20 and with spaces, also with a "\" at the end of the URL, but with no success.

jdMorgan

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



 
Msg#: 3210546 posted 10:34 pm on Jan 6, 2007 (gmt 0)

You don't need more than one RewriteEngine on directive in the file -- at the top.

I can't remember which of these will do it, but one of them will:

RewriteRule ^Folder\ with\ three\ spaces/page\.htm$ - [G]
#
RewriteCond %{REQUEST_URI} ^Folder\ with\ three\ spaces/page\.htm$
RewriteRule ^Folder - [G]
#
RewriteCond %{REQUEST_URI} ^Folder\%20with\%20three\%20spaces/page\.htm$
RewriteRule ^Folder - [G]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /Folder\%20with\%20three\%20spaces/page\.htm\ HTTP/
RewriteRule ^Folder - [G]

Also, put the simplest one of these that works above your domain redirect rule -- There's no use redirecting the domain and then returning a 410 for this file.

The URL-paths seen by RewriteRule, by RewriteCond in %{REQUEST_URI}, and by RewriteCond in %{THE_REQUEST} undergo various degrees of un-encoding, from most to least, respectively.

Jim

joergnw10

5+ Year Member



 
Msg#: 3210546 posted 11:52 am on Jan 7, 2007 (gmt 0)

Thanks Jim, the first version is working (so I didn't try the others).
And thanks for the other tips, too!

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