This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: RewriteRule with space in output
Author
Message |
elber73
Newbie


Joined: 29 September 2010
Posts: 6
Posted: 01 October 2010 at 5:30am

Hello, all that I tried doesn't work

GMail transform the spaces in url with plus sign.

I have for example the follow original url:
http://www.myserver.com/folder/Sept 2010

In GMail it is shown as follow:
http://www.myserver.com/folder/Sept+2010

And that url give a 404 in my server. I know the problematic with spaces in urls, but my customers not.

I am trying the follow rule for that single case "folder/Sept 2010" to trying isolate the problem, that must change plus sign by "%20" in the url, but doesn't work:

 RewriteEngine on
 RewriteBase /
 RewriteRule ^folder/Sept\+2010$ /folder/Sept%202010 [R=301,NE,L]

I have the R=301 as I can see the resultant url.
I always give as result the follow url:

http://www.myserver.com/folder/Sept02010

I don't know why the plus sign it is changed by a "0" digit.

Any help would be appreciated.

 

Back to Top Visit elber73's Homepage
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 01 October 2010 at 8:19am

Hello,
Please try the following rule:
Code:
RewriteEngine on
RewriteBase /
RewriteRule ^([^+]+)\+(.*)$ $1%20$2 [LP,R=301]


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
elber73
Newbie


Joined: 29 September 2010
Posts: 6
Posted: 01 October 2010 at 12:42pm

Not luck.

It is transformed to the same:
http://www.myserver.com/folder/Sept02010

It seem that the %20 on the mod_rewrite output have this problem.
Perhaps it is something specific of my web or server.

As test, if I change to another character, not %20, the rewrite is well done.

Someone have tried it?



Edited by elber73 - 01 October 2010 at 12:44pm
Back to Top Visit elber73's Homepage
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 02 October 2010 at 5:49am

Hello,
Please try the following code:
Code:
RewriteEngine on
RewriteBase /
RewriteRule ^([^+]+)\+(.*)$ $1\%20$2 [LP,R=301]


If it doesn’t work, please provide me with rewrite.log file.

Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
elber73
Newbie


Joined: 29 September 2010
Posts: 6
Posted: 02 October 2010 at 6:30am

Not working, with last rule I get a 400 response code.

rewrite.log for rule ^([^+]+)\+(.*)$ $1\%20$2 [LP,R=301]

[www.myserver.com/sid#3751][rid#52133063/initial] (1) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] init rewrite engine with /revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#52133063/initial] (5) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] strip matching prefix: /revistas/Septiembre+2010 -> revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#52133063/initial] (3) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] applying pattern ^([^+]+)\+(.*)$ to uri revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#52133063/initial] (5) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] add per-dir prefix: revistas/Septiembre%202010 -> /revistas/Septiembre%202010
[www.myserver.com/sid#3751][rid#52133063/initial] (2) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] escaping /revistas/Septiembre%202010
[www.myserver.com/sid#3751][rid#52133063/initial] (2) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] forcing responsecode 301 for http://www.myserver.com/revistas/Septiembre%25202010
[www.myserver.com/sid#3751][rid#52133063/initial] (3) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] applying pattern ^([^+]+)\+(.*)$ to uri /revistas/Septiembre%202010

In addition, rewrite.log for rule without the backslash ^([^+]+)\+(.*)$ $1%20$2 [LP,R=301]

[www.myserver.com/sid#3751][rid#25702951/initial] (1) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] init rewrite engine with /revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#25702951/initial] (5) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] strip matching prefix: /revistas/Septiembre+2010 -> revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#25702951/initial] (3) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] applying pattern ^([^+]+)\+(.*)$ to uri revistas/Septiembre+2010
[www.myserver.com/sid#3751][rid#25702951/initial] (5) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] add per-dir prefix: revistas/Septiembre02010 -> /revistas/Septiembre02010
[www.myserver.com/sid#3751][rid#25702951/initial] (2) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] escaping /revistas/Septiembre02010
[www.myserver.com/sid#3751][rid#25702951/initial] (2) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] forcing responsecode 301 for http://www.myserver.com/revistas/Septiembre02010
[www.myserver.com/sid#3751][rid#25702951/initial] (3) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] applying pattern ^([^+]+)\+(.*)$ to uri /revistas/Septiembre02010

[www.myserver.com/sid#3751][rid#61575639/initial] (1) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] init rewrite engine with /revistas/Septiembre02010
[www.myserver.com/sid#3751][rid#61575639/initial] (5) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] strip matching prefix: /revistas/Septiembre02010 -> revistas/Septiembre02010
[www.myserver.com/sid#3751][rid#61575639/initial] (3) [perdir c:\inetpub\vhosts\myserver.com\httpdocs\] applying pattern ^([^+]+)\+(.*)$ to uri revistas/Septiembre02010

I removed ip columns.

Thanks.



Edited by elber73 - 02 October 2010 at 6:30am
Back to Top Visit elber73's Homepage
 
elber73
Newbie


Joined: 29 September 2010
Posts: 6
Posted: 02 October 2010 at 6:36am

Yeahh! It's solved.

Final rule that work ok is (with backslash and with NE):
RewriteRule ^([^+]+)\+(.*)$ $1\%20$2 [LP,NE,R=301]

Thanks to you, of course!!

Back to Top Visit elber73's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version