close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

best practice for broken URLS

Thread began 6/10/2016 2:47 pm by Christopher West | Last modified 6/13/2016 10:07 am by santius355196 | 971 views | 5 replies |

Christopher WestCommunity Expert

best practice for broken URLS

Hi lets say I have URL: http://localhost/armadillo/category.php?Department=Lighting which works fine, and now lets say if the URL was mistyped, for example missing the last 2 letters, like so: http://localhost/armadillo/category.php?Department=Lighti

What would be the sensible way of redirecting the customer to a friendly page (otherwise it will default to a page with incomplete content)

Chris

Sign in to reply to this post

CraigRBeta Tester

off the top of my head possibilities

Hi Chris,

I can think of 2 options for this.

you could consider a wildcard in the search, so that even if the url was mistyped, it would still find a result, ie department like %lighti%

alternatively' you could consider a conditional php redirect, so that if the search returns no results, redirect to another page (noresults.php)

you could also pass the url parameter to the noresults page and use this in the content and as a more general search parameter, with a message like, 'you typed this', there is nothing, these are the closest match..., with links back to the relevant page.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Craig, I got my search no results page all sorted thanks. My original question relates to other pages, well relating to my category listing pages, since the category listing page shows results based on the URL and let's say for what ever reason, the last few letters were cut off from the URL (maybe an incorrect copy/paste of a URL) so since the URL won't return any results but the page will still display but with blank areas.

Same idea for product pages. Let's say for argument sake that product ID 45 doesn't exist. But if you were to have a URL that ends with ProductID=45 then it will still display the page, but the dynamic elements wouldn't be missing.

Does this make sense?

Chris

Sign in to reply to this post

CraigRBeta Tester

Can I go through it step by step, as I am not quite sure I am getting what you want.
(A screenshot may help me ?)
Lets take the ProductID = 45 as an example.
If this product doesn’t exist, then no rows are returned from the recordset. - what do you want to do then ?
Do you want to display something on the current page, ie a message saying that this item does not exist ?
Or do you want to redirect to another page ?
Either way, couldn’t you just put the relevant code in a conditional block ?

<?php if ($recordset->TotalRows == 0) { // Show if mysqli recordset empty ?>

….
<?php }?>



Or something else ?

Sign in to reply to this post

Christopher WestCommunity Expert

I am a fool lol yes that's exactly what I needed to do and actually did it for another page....I was over thinking the solution I was going to do a redirect to be honest to the home page since there be nothing to display on the product page if there are no results. But can do an if statement. I think I had in my mind to do some type of condition at the top of the page above the HTML body where all my other php resides. A little bit like what ecart does as I've noticed redirects if no basket etc.

Chris

Sign in to reply to this post

CraigRBeta Tester

re: "I am a fool"

Happens to me all the time ;-)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...