Re: Apache Rewrite Issues
| From: | Tommy Pham | Date: | Wed, 07 Oct 2009 20:28:27 +0000 |
| Subject: | Re: Apache Rewrite Issues | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298750@lists.php.net to get a copy of this message | ||
----- Original Message ----
> From: Russell Seymour <russell.seymour@turtlesystems.co.uk>
> To: php-general@lists.php.net
> Sent: Wed, October 7, 2009 3:52:00 AM
> Subject: [PHP] Apache Rewrite Issues
>
> Morning,
>
> I am trying to make my URLs more search engine friendly and I have come up
> against a problem.
>
> I want the following URL:
>
> mysite.example.com/articles/Test Story
>
> to be proxied to
>
> mysite.example.com/index.php?m=articles&t=Test%20Story
>
Russell,
Consider using a string function to replace the space with _ to be really SEF/SEO when generating
the URL. Thus, your problem also disappears ;)
Regards,
Tommy
> I have the following rule in my Apache conf
>
> RewriteRule ^/articles/(.*) index.php?m=articles&t=$1 [P,L]
>
> Now if I run with this configuration, PHP strips the query string back at the
> space, so my query string ends up looking like
>
> [QUERY_STRING] => m=articles&t=Test
>
> even though the log file for the rewrite shows that the full query is being
> passed.
>
> But if I change the RewriteRule to be a Rewrite instead of a Proxy I get
>
> [QUERY_STRING] => m=articles&t=Test%20Story
>
> So something is happening when the system is proxying the request.
> Adding %20 into the URL does not fix the problem when proxy is enabled either.
>
> I have search around on the Internet, and people talk about using urlencode etc,
> this is fine when
> PHP is creating the URL but not when Apache is doing the rewrite.
>
> I apologise if people feel this is on the wrong list, but as far as I can tell
> from the rewrite logs the data is coming all
> the way through to PHP which is truncating it. This is purely my observation.
>
> Apache version: 2.2.11
> PHP Version: 5.3.0
>
> Any help is gratefully recieved.
>
> Thanks, Russell