Title: Help. 404 error
Last modified: August 21, 2016

---

# Help. 404 error

 *  [yalanger1976](https://wordpress.org/support/users/yalanger1976/)
 * (@yalanger1976)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/help-404-error-3/)
 * Hello,
 * I installed this plugin and I’m having trouble making it work. I’m new to WordPress
   so was hoping someone can help me out.
 * I’m looking to set up the following pages for example
    [http://testsite.azurewebsites.net/Services/Services1](http://testsite.azurewebsites.net/Services/Services1)
   [http://testsite.azurewebsites.net/Services/Services2](http://testsite.azurewebsites.net/Services/Services2)
 * I do the following steps
    1. Add New Page 2. Enter the following title “Services1”
   3. Enter the following text in the Permalink textbox “Services/Services1” replacing
   the default text “?page_id=140” 4. Then I publish the page. 5. This automatically
   updates the “Custom Fields” section below. The name is set to “custom_permalink”
   and the value is set to “Services/Services1”. 6. Then I “view page” but get a
   404 error. The url is “[http://testsite.azurewebsites.net/Services/Services1&#8221](http://testsite.azurewebsites.net/Services/Services1&#8221);
 * Some additional info
    1. WordPress version 9.8.3 2. Settings – Permalinks is 
   set to “post name” 3. Custom Permalinks version 0.7.18
 * Any help would be greatly appreciated.
 * Thanks
 * [https://wordpress.org/plugins/custom-permalinks/](https://wordpress.org/plugins/custom-permalinks/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * (@mathewcantore)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/help-404-error-3/#post-4815292)
 * The problem is with mysql_real_escape_string in custom_permalinks.php. There 
   seem to be some solutions online, but I found simply removing that part of the
   code worked best for now, at least if you’re familiar with doing so.
 *  [Kramarz](https://wordpress.org/support/users/kramarz/)
 * (@kramarz)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/help-404-error-3/#post-4815299)
 * Looks like we need an update for 3.9 indeed 🙂
 *  [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * (@mathewcantore)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/help-404-error-3/#post-4815305)
 * In the WP plugins directory, in custom-permalinks, in custom-permalinks.php find
   the following lines:
 * >  $sql = “SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type
   > FROM $wpdb->posts “.
   >  “LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb-
   > >postmeta.post_id) WHERE “. ” meta_key = ‘custom_permalink’ AND “. ” meta_value!
   > = ” AND “. ” ( LOWER(meta_value) = LEFT(LOWER(‘”.mysql_real_escape_string($
   > request_noslash).”‘), LENGTH(meta_value)) OR “. ” LOWER(meta_value) = LEFT(
   > LOWER(‘”.mysql_real_escape_string($request_noslash.”/”).”‘), LENGTH(meta_value)))“.”
   > AND post_status != ‘trash’ AND post_type != ‘nav_menu_item'”. ” ORDER BY LENGTH(
   > meta_value) DESC, “. ” FIELD(post_status,’publish’,’private’,’draft’,’auto-
   > draft’,’inherit’),”. ” FIELD(post_type,’post’,’page’),”. “$wpdb->posts.ID ASC
   > LIMIT 1”;
 * Replace them with:
 * >  $sql = $wpdb->prepare(“SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value,
   > $wpdb->posts.post_type FROM $wpdb->posts “.
   >  “LEFT JOIN $wpdb->postmeta ON (
   > $wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “. ” meta_key = ‘custom_permalink’
   > AND “. ” meta_value != ” AND “. ” ( LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(
   > meta_value)) OR “. ” LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(meta_value)))“.”
   > AND post_status != ‘trash’ AND post_type != ‘nav_menu_item'”. ” ORDER BY LENGTH(
   > meta_value) DESC, “. ” FIELD(post_status,’publish’,’private’,’draft’,’auto-
   > draft’,’inherit’),”. ” FIELD(post_type,’post’,’page’),”. “$wpdb->posts.ID ASC
   > LIMIT 1”,$request_noslash,$request_noslash . “/”);
 * This restored my permalinks to working order. As always, make a backup of the
   custom-permalinks.php file before modifying it in case something goes horribly
   wrong. Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Help. 404 error’ is closed to new replies.

 * ![](https://ps.w.org/custom-permalinks/assets/icon.svg?rev=1785367)
 * [Custom Permalinks](https://wordpress.org/plugins/custom-permalinks/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-permalinks/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-permalinks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-permalinks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-permalinks/reviews/)

## Tags

 * [404-error](https://wordpress.org/support/topic-tag/404-error/)

 * 3 replies
 * 3 participants
 * Last reply from: [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/help-404-error-3/#post-4815305)
 * Status: not resolved