Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess redirect when there is a space in url

I want to redirect from a old url which still appears in the google search to the new one. the old url is this:

http://www.marionettecolla.org/file%20_mostra_milano/mostra_marionette-milano.htm

and I want to redirect it to the home page:

http://www.marionettecolla.org/

I used this in my .htaccess:

Redirect http://marionettecolla.org/file\ _mostra_milano/mostra_marionette-milano.htm http://marionettecolla.org/

but I am getting Error 500... Does anybody know how to solve this problem?

like image 393
mahsa.teimourikia Avatar asked Oct 01 '12 09:10

mahsa.teimourikia


3 Answers

this should works:

Redirect 301 "http://marionettecolla.org/file _mostra_milano/mostra_marionette-milano.htm" http://marionettecolla.org/

just put it between pair of double-quotes " ... "

Update:

This is another way also, should works for any kind of spaces:

redirectMatch 301 http://marionettecolla.org/file[\s]_mostra_milano/mostra_marionette-milano.htm http://marionettecolla.org/
like image 150
Mahdi Avatar answered Nov 14 '22 03:11

Mahdi


You can't just escape space like that "\ ". The proper way to do it is "\s".

Although I am not sure if putting "\s" in place of space in htaccess file would do the trick. Please let me know if it worked.

like image 13
user1581900 Avatar answered Nov 14 '22 04:11

user1581900


Try this it works even we tested:

redirect 301 "/file _mostra_milano/mostra_marionette-milano.htm" http://marionettecolla.orgx/" http://marionettecolla.org

Posted by

alapati

like image 3
kumar sat Avatar answered Nov 14 '22 04:11

kumar sat