Jump to content

Strange 404 after adding field value?


photoman355
 Share

Recommended Posts

I've just come across a really strange problem where processwire is throwing a 404 error after I enter a value into one of my fields.  I'm sure this is probably down to my code.  

I have a set of fields that when a value is entered some output is echoed to my template.  Every field works as expected except the last field which throws the 404 after entering a value and saving the page.  

Here's the code.

 <?php 
$settings = $pages->get("/site-settings/");

if ($settings->social_facebook) echo "<li><a class='icon-small small-icon-facebook' href='{$settings->social_facebook}' target='_blank'></a></li>";
if ($settings->social_twitter) echo "<li><a class='icon-small small-icon-twitter' href='{$settings->social_twitter}' target='_blank'></a></li>";
if ($settings->social_linkedin) echo "<li><a class='icon-small small-icon-linkedin' href='{$settings->social_linkedin}' target='_blank'></a></li>";
if ($settings->social_youtube) echo "<li><a class='icon-small small-icon-youtube' href='{$settings->social_youtube}' target='_blank'></a></li>";
if ($settings->social_picasa) echo "<li><a class='icon-small small-icon-picasa' href='{$settings->social_picasa}' target='_blank'></a></li>";
if ($settings->social_upon) echo "<li><a class='icon-small small-icon-stumble' href='{$settings->social_upon}' target='_blank'></a></li>";
?>

I'm guessing there's a better way to write this but not quite sure why it's throwing an error.  I've tried deleting and recreating the last field with a different name but it still throws the same error.

Can anyone help?

Link to comment
Share on other sites

Thanks Soma.  I don't understand what's causing the 404 as all I'm doing is saving a field value on an admin page.  The field isn't redirecting any urls it's only a textfield to provide output for the template.  

Is there a procedure to troubleshoot?

Link to comment
Share on other sites

so in other words you have a text field called social_upon and when you enter data into that field and save, you get a 404 error.

You should post the URL that PW is redirecting to on save;

try disabling some modules also, to account for possible conflicts; also post screenshot ?

Link to comment
Share on other sites

@Soma I only thought the template code was at fault because everything worked up until I added the new code.

@Macrura That's correct, entering data into any of the other text fields and saving works fine but for some strange reason entering data into social_upon and saving throws the 404.  This happens even if I empty one of the other fields and fill the social_upon field.  I've tried creating a new field with a different name but no joy.

For URL's the page is at mydomain.com/login/page/edit/?id=1011.  When I hit save I get the 404 error message "The page you were looking for is not found.Please use our search engine or navigation above to find the page.".  The URL on that page is exactly the same.

As I'm developing I still have the default site template and it's relevant files installed (my home.php has been modified).  My new template calls a different header, footer and template files. It's redirecting to the default install template page possibly because it's assigned as the default for 404's? 

Modules wise I don't have many installed outside the default ones just, Fieldtype Crop Image, CK Editor, HTML Purifier, Modules Manager and Process Page Delete.

Is there anything I should try?  

Link to comment
Share on other sites

mydomain.com/login/page/edit/?id=1011 ... is /login/ you PW admin/installation?

It's just I'm not sure where template files would be involved in backend editing? This is not possible I think.

What fields are they? What data do you enter extactly? The only scenarion that comes to mind is that you enter some data in that last field that is suspicious and maybe some security setting on server does not allow for posting those through a form and you get a 404... But maybe not.

Ok seeing the modules list, try deinstalling some of those like Process Page Dele, Modules Manager, HTML Purifier?

Link to comment
Share on other sites

yes it sounds like you're getting booted from the admin, or there is some error going on, perhaps with duplicates in the database...

one thing i would try is repairing the database, you can login to your phpMyAdmin and run the database repair

Link to comment
Share on other sites

@soma Yes I changed the default login from /processwire to /login mainly to make it more memorable for clients.

For setup I have 6 textfields (all use the default settings) and the last textfield is what I'm having trouble with.  I did get a little further on today.  Tried repairing the database as Macrura suggested which all checked out fine.  I then returned to the admin and entered some different data with some success.  

What I was entering before was a URL in the format "http://www.google.com" and saving the page throws an error.  I changed the entry to "www.google.com" and the page saves fine, no 404.  Very strange.  Next I changed the last field from a textfield to a URL.  Now when I go back to the admin page in question the URL field re-writes the last entry from "www.google.com" to  "http://www.google.com".  When I hit save I get the 404 again.

It's clearly something to do with the "http://" part of the entry.  Soma you suggested this could be server security. Can you explain a bit more?

Just something else to add.  I'm currently testing out the multisite install and this particular database is a clone from another of my PW sites.  I just exported the database from a master site and imported into a new database via phpmyadmin.  I don't know if this is significant or not?  

Link to comment
Share on other sites

It's clearly something to do with the "http://" part of the entry.

I'm assuming the 404 you are getting is an Apache one rather than a ProcessWire one. You are seeing mod_security in action. When mod_security gets in the way of legitimate content management, then it's configured in an overly agressive manner. I would ask your host to loosen things up a bit, or if they can't, have them disable mod_security for your account. 

  • Like 1
Link to comment
Share on other sites

Aha that would make sense as my hosting company has been pretty poor of late.  Many thanks for the info Ryan.  How would I tell if this is definitely an Apache 404 vs a Processwire one?  

I've been in touch and asked them to lighten up the security rules and they said they've changed them but I'm still having issues.  Before I go back to them I thought I'd try to disable mod_security using htaccess.  I added "SecFilterEngine Off" to htaccess but after adding it locks me out of my PW site.  I don't have much experience on the server side so I've probably tried to change completely the wrong setting.

Is there a correct way to manually disable mod_security so I can check this is definitely the problem?  I have access to cpanel if that helps.

Link to comment
Share on other sites

 How would I tell if this is definitely an Apache 404 vs a Processwire one?  

The ProcessWire 404 will look like your site. The Apache 404 will look like plain text. Though I actually think this is mod_security either way. 

Is there a correct way to manually disable mod_security so I can check this is definitely the problem?

I think this is something that only your host can answer. Though if someone else knows better, hopefully they will reply. 

Link to comment
Share on other sites

Many thanks Ryan.  The 404 the page in question is a site-settings page that has no associated template file.  Would a processwire 404 from this page not be output as plain text anyway as there's no header and footer or would a 404 still show the admin header and footer?

I'm sure you're right in saying it's mod_security anyway.  My hosting company are useless :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...