Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Hello.

I have pretty URLs working well. For example:

...www.mysite.com/pages.php --> BECOMES --> ...www.mysite.com/pages/some-page-within-pages

But there is one exception. Any URL that has a query string following the page name doesn't compute. For example:

...www.mysite.com/pages.php?productpages=manuals --> BECOMES --> <ERROR>

Using the example above, I would probably like the URL with the query string to show up like the following:

...www.mysite.com/pages.php/products

Is there a block of .HTACCESS code that I can use to catch querystring URLs and convert them as I like?

I could grab an existing pretty urls code block from my HTACCESS page and alter it as you may recommend.

Thank you.
Hi,

The prettyURL formats used by Couch are hard-coded and do not allow any changes, I am afraid.

That said, with the inbuilt settings we can still use querystring params e.g. something like this -
Code: Select all
www.mysite.com/pages.php?someparam=somevalue
should be accessible as follows -
Code: Select all
www.mysite.com/pages/?someparam=somevalue

Possibly you have tried modifying the generated .htaccess rules manually and that could be causing the error.
Please check.
Very interesting. Thank you.

Yes, I did do something manually with the pretty urls htaccess file. When I ran the HTACCESS AUTO-GENERATION script, some of my template pages were skipped -- no htaccess elements were made for them -- so what I did was copy and paste a block of code for one page, changing the file name wherever it appeared within the copied block.

So there could be something going on there.

Also, if it is relevant, in pages.php, there is some PHP code that takes the query string and fetches a list of items that match it inside the <cms:pages> block.

Let me have a closer look at the blocks that I copies and altered though.

Thanks, KK.
I looked at the .htaccess file. Something I found:

First, I do have a URL with query string that works.

The URL with query string that does not work has a difference that might be the cause of the problem: there is a space in the value part of the query. Like this:

...www.mysite.com/pages/?productpages=Instruction Sets

Could this be the problem? If so, I will alter my PHP to remove the space.
there is a space in the value part of the query

Querystring params do not allow raw spaces (and several other characters); so, yes, having that space will cause trouble.

To be querystring safe, those problem characters need to be properly encoded (e.g. space as '%20').
in PHP you can use the urlencode() function to do that. Sample usage -
Code: Select all
$param = "productpages=" . urlencode( "Instruction Sets" );

Hope this helps.
Thank you, KK.
I am not certain of this, but I think I may have fixed an issue or two by inserting a slash in front of some of my relative links.

QUERY STRING ISSUE --> FIXED?

1. The query string issue that I had when I turned on pretty urls might have been fixed by altering the hrefs, by inserting a slash in front of the relative link that I was using to the page that had the query string attached.

HTACCESS AUTO-GENERATION PROBLEM --> FIXED?

2. The issue I had with pretty urls where the auto-htaccess-generation script skipped lots of my pages -- this also might have been solved via the same method. The slash may have overridden an inadvertent base url problem.

I didn't isolate the fixes above; I mean, I didn't test them definitively; but I feel as though these would be good things to try for anyone who has similar issues.

Thank you again for your help.
inserting a slash in front of the relative link

It sounds like you are not using <cms:link> tag, which is a recommended practice for all links in pretty-urls setup.
Oh, wow. I'm looking into this right now. Thank you, Trendoman.
9 posts Page 1 of 1