Welcome to WebmasterWorld Guest from 23.22.79.235

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirecting urls with special characters

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

5+ Year Member




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)

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



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

5+ Year Member



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)

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



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)

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



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.