0

I have 2 websites both built in ExpressionEngine 3.5.10.

Both use the {exp:search:simple_form} tag to provide a basic search facility.

One of the sites works absolutely fine. But the other doesn't - if I do a search for a valid term (by looking at the content in the Admin panel) it will give me a list of results, but the URL to the entry is incorrect. So it results in a 404 error when the user clicks on a result.

The search form syntax is like this:

 {exp:search:simple_form channel="news|services|resources|contact_us|about_us|pages|team" no_result_page="search/noresults" results="10" search_in="entries" status="open" where="any"}   

I have a few entries in the services channel. If I search for a valid phrase within the content it is producing these URLs:

The above will result in 404 errors - the correct URL has services before the slug. So they should be:

The syntax in my results template (search/results.html) to display the URL's is the same on both websites:

{exp:search:search_results}
    <a href="{auto_path}">{title}</a>
    <p>{excerpt}</p>
{/exp:search:search_results}

The problem seems to be arising from the {auto_path} bit because that's what's outputting the URL.

I'm unsure why it works ok on 1 website and not the other. They are separate websites but am sure they have been set up and configured in the same way.

Is there some other setting needed to make my URLs work correctly? Very confusing and slightly annoying that this doesn't just work out of the box.

1

I figured this out, but the way it works is really really bad!

If you go into Channels > services > Search results you have to specify the URL to that channel's template group, e.g. https://my.domain/services

This will then produce the "correct" URL on the search results page (for example https://my.domain/services/tech-page-1 instead of https://my.domain/tech-page-1).

This is an absolutely terrible system, because not only do you have to do that for every channel (7 in my case)... but if you're working in a development/staging environment you then have to replace all those URL's during go-live rather than it working off 1 setting!

Incidentally if anyone has a better workaround let me know. Although that's "fixed" my problem, the underlying system is absolutely awful.

2
  • 1
    You don't need to put the whole URL into the search results entry box. You can either just start it with a / or to be more correct put in {base_url} followed by the appropriate path. So you could use (for example): {base_url}/services If you do then you won't have to change each entry when you move from staging server to live - just the one for base URL (which you would have to change anyway). HTH – JCOGS Design Oct 10 '17 at 14:42
  • Thanks @jcogs.eecms that works really well. I didn't know about the {base_url} tag in those settings, that's good and negates my comment about it not being a very good system! – Andy Oct 10 '17 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.