Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirecting urls with special characters

     
10:35 am on Nov 15, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 12, 2010
posts: 49
votes: 0



System: The following message was cut out of thread at: http://www.webmasterworld.com/apache/4518100.htm [webmasterworld.com] by incredibill - 2:52 pm on Nov 17, 2012 (PST -8)


and how would you redirect a url like this:

www.example.com/our-work/%ourworkcategories%/ (Bad request)

to:

example.com/our-work/
1:00 am on Nov 18, 2012 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


what have you tried?
3:15 pm on Nov 20, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 12, 2010
posts: 49
votes: 0


I tried this, but it only works for /%20 or spaces

eg. when you want to redirect something like this:

www.example.com/our%20work

example:
Redirect 301 "/our work" "http://www.example.com/our-work"

but this doesn't work for bad requests like below.
www.example.com/our-work/%ourworkcategories%/

any help would be appreciated.
3:27 pm on Nov 20, 2012 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


you could probably get this working with the RedirectMatch Directive:
http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch

however i would suggest using mod_rewrite instead of mod_alias.

mod_rewrite - Apache HTTP Server:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html [httpd.apache.org]
8:08 pm on Nov 20, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


You will probably need to use mod_rewrite for the mechanical part. But the first thing you need to do is figure out exactly what bad URLs are involved, and where they are coming from.

If they are bogus URLs --ones that you didn't make yourself, and didn't come from typos on a site you like-- you don't have to redirect them at all. Let them go to a well-earned 404.