Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

RewriteRule help please

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


adam.p.reynolds at gmail

Nov 23, 2009, 3:15 AM

Post #1 of 5 (410 views)
Permalink
RewriteRule help please

Hi All,

I have the following rewrite rule ..

RewriteRule products/specials(.*)(.*)
/products/index.php?view=specials&$1=$2 [L]

http://www.mysite.com/products/specials&filter=20
--> http://www.mysite.com/products/index.php?view=specials&filter=20=

The problem is the trailing '='

I have also tried RewriteRule wheels/specials([0-9]+)
/wheels/index.php?view=specials&$1 [L]
but this rule results in internal server errors.

Thanks in advance.


--
View this message in context: http://old.nabble.com/RewriteRule-help-please-tp26475922p26475922.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


phil at philipwigg

Nov 23, 2009, 3:32 AM

Post #2 of 5 (382 views)
Permalink
Re: RewriteRule help please [In reply to]

> I have the following rewrite rule ..
>
> RewriteRule products/specials(.*)(.*)
> /products/index.php?view=specials&$1=$2 [L]
>
> http://www.mysite.com/products/specials&filter=20
> --> http://www.mysite.com/products/index.php?view=specials&filter=20=
>
> The problem is the trailing '='
>
> I have also tried RewriteRule wheels/specials([0-9]+)
> /wheels/index.php?view=specials&$1 [L]
> but this rule results in internal server errors.

One problem in your first rule is that the '(.*)(.*)' part. (.*)(.*)
is functionally equivalent to just a single (.*), so your $2 will
always be empty (this is causing the trailing =). Maybe just try:-

RewriteRule products/specials(.*) /products/index.php?view=specials&$1 [L]

If that's not what you're after, I think I'd need a couple of examples
of the URL you're trying to rewrite and what you're expecting it to be
rewritten to, as I don't completely understand it at the moment.

Cheers,
Phil.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


adam.p.reynolds at gmail

Nov 23, 2009, 3:57 AM

Post #3 of 5 (383 views)
Permalink
Re: RewriteRule help please [In reply to]

Hi Phil,

Thanks for the reply.

I changed the rule to use a single (.*) but the result was the same.

Here is an example of the url entered ..
http://www.mysite.com/products/specials&filter=20

and expecting

http://www.mysite.com/products/index.php?view=specials&filter=20

RewriteRule products/specials(.*) /products/index.php?view=specials&$1=$2
[L]

The rewritten url is close but still has the trailing '='.

Thanks.
Adam



Philip Wigg wrote:
>
>> I have the following rewrite rule ..
>>
>> RewriteRule products/specials(.*)(.*)
>> /products/index.php?view=specials&$1=$2 [L]
>>
>> http://www.mysite.com/products/specials&filter=20
>> --> http://www.mysite.com/products/index.php?view=specials&filter=20=
>>
>> The problem is the trailing '='
>>
>> I have also tried RewriteRule wheels/specials([0-9]+)
>> /wheels/index.php?view=specials&$1 [L]
>> but this rule results in internal server errors.
>
> One problem in your first rule is that the '(.*)(.*)' part. (.*)(.*)
> is functionally equivalent to just a single (.*), so your $2 will
> always be empty (this is causing the trailing =). Maybe just try:-
>
> RewriteRule products/specials(.*) /products/index.php?view=specials&$1 [L]
>
> If that's not what you're after, I think I'd need a couple of examples
> of the URL you're trying to rewrite and what you're expecting it to be
> rewritten to, as I don't completely understand it at the moment.
>
> Cheers,
> Phil.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> " from the digest: users-digest-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>
>

--
View this message in context: http://old.nabble.com/RewriteRule-help-please-tp26475922p26476797.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


phil at philipwigg

Nov 23, 2009, 4:08 AM

Post #4 of 5 (383 views)
Permalink
Re: RewriteRule help please [In reply to]

> RewriteRule products/specials(.*) /products/index.php?view=specials&$1=$2 [L]
>
> The rewritten url is close but still has the trailing '='.

What you've put there is different to what I suggested, since you've
kept the =$2 at the end. I still have a feeling this won't be totally
what you need though. Looking at your original URL:-

http://www.mysite.com/products/specials&filter=20

this would seem to be missing a ? to start passing arguments. I would
think it should be:-

http://www.mysite.com/products/specials?filter=20

And I'm not sure if this will cause you problems, I suspect it might.

Regards,
Phil.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


adam.p.reynolds at gmail

Nov 23, 2009, 4:16 AM

Post #5 of 5 (381 views)
Permalink
Re: RewriteRule help please [In reply to]

Thanks Phil.

You just fixed my issue.

Much appreciated.


Philip Wigg wrote:
>
>> RewriteRule products/specials(.*) /products/index.php?view=specials&$1=$2
>> [L]
>>
>> The rewritten url is close but still has the trailing '='.
>
> What you've put there is different to what I suggested, since you've
> kept the =$2 at the end. I still have a feeling this won't be totally
> what you need though. Looking at your original URL:-
>
> http://www.mysite.com/products/specials&filter=20
>
> this would seem to be missing a ? to start passing arguments. I would
> think it should be:-
>
> http://www.mysite.com/products/specials?filter=20
>
> And I'm not sure if this will cause you problems, I suspect it might.
>
> Regards,
> Phil.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> " from the digest: users-digest-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>
>

--
View this message in context: http://old.nabble.com/RewriteRule-help-please-tp26475922p26477034.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
" from the digest: users-digest-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.