Some thoughts:

This isn't going to work as is because `$url` may already have a path set due to line 188.

Ideally, you should use `urlFor()` and assign directly to to `$url` rather than using concatenation as that way we can change URLs without breaking this code.

Finally, don't forget that you may need to url_encode `$keyword` and ensure that page is a number.