Paged/Pagination Not Working on URL Rewrite Rule

add_action('init', 'do_rewrite'); function do_rewrite(){     add_rewrite_rule('^shop/men/?$  ', 'index.php?post_type=product&product_tag=men', 'top');     add_rewrite_rule('^shop/men/page/([0-9]{1,})/?$  ', 'index.php?post_type=product&product_tag=men&paged=$  matches[1]', 'top');     flush_rewrite_rules(); } 

The first rewrite rule works great. https://www.example.com/shop/men/ goes directly to https://www.example.com/shop/?post_type=product&product_tag=men with the post_type and product_tag filtered as expected.

Now, if I go to https://www.example.com/shop/?post_type=product&product_tag=men&paged=2

The query and filters in the url, including the new paged of 2, works as intended.

So I assumed my rewrite rule would work the same. But instead it just goes straight to my 404 Page Not Found Error Page.

When I do go to the link with the paged=2 query in the url, it does do a redirect to https://www.example.com/tag/men/page/2/?post_type=product

So my best guess is that there may be some overlap of some sort causing the issue… but I am not sure where to go from here. How can I get my paginated rewrite rule to work with the url https://www.example.com/shop/men/page/2 .../shop/men/page/3 and so forth in my add_rewrite_rule?

How to rewrite URL with PHP variables with htaccess to a normal looking URL?

I have a problem. I want to change an old database website that is not made in WordPress to WordPress. My site uses PHP variables So the URL is originally:

website.com/index.php?tl=1&pg=2&bs=3&hcbs=4&sc1bs=5&sc2bs=6&sc3bs=7&hc=8&blbs=9

But I could rewrite that to a normal looking url:

website.com/1/2/3/4/5/6/7/8/9.php

To do that in the old site I used the following rewrite rules in the .htaccess file:

RewriteEngine on  RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3&hcbs=$  4&sc1bs=$  5&sc2bs=$  6&sc3bs=$  7&hc=$  8&blbs=$  9 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3&hcbs=$  4&sc1bs=$  5&sc2bs=$  6&hc=$  7&sc3bs=$  8 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3&hcbs=$  4&sc1bs=$  5&hc=$  6&sc2bs=$  7 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3&hcbs=$  4&hc=$  5&sc1bs=$  6 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3&hc=$  4&hcbs=$  5 [L] RewriteRule ^(.*)/(.*)/(.*).php ?tl=$  1&pg=$  2&bs=$  3 [L] 

But now I am trying to do so in WordPress. WordPress already has some preinstalled rewrite rules:

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$   - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> 

But when I try to combine the both in any way the complete wordpress site stops working. Does anyone have an idea how to solve this?

Looking forward for your replies

Greetings

Hanno

SEO Rewrite , URI Without .php Extension To file [duplicate]

I have website with this output Link :

https://domain1.net/estates.php?estname=XXXX&location=YYYYY 

I want change it to :

https://domain1.net/XXXXX/YYYYY 

I try it with following rewrite rule :

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/([^/]*)/?$   /estates.php?estname=$  1&location=$  2 [L] 

or

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^-]*)/([^-]*)/?$   /estates.php?estname=$  1&location=$  2 [L] 

but result not work fins , means when test it site design break down and pic and CSS element not loading .

how to rewrite this formula

Using /. (Or[a_ && b_]) :> {b, a} // Apply[Piecewise[{##}] &] can easily convert output from Reduce into a piecewise function.

for example: https://mathematica.stackexchange.com/a/212196/68689

but in following situation:

Reduce[RealAbs[x] + 2 RealAbs[x - 2 a] >= 4, x, Reals] 

gives

a <= -2 || (-2 <  a <= -1 && (x <= 1/3 (-4 + 4 a) || x >= 4 + 4 a)) || (-1 < a <=  1 && (x <= 1/3 (-4 + 4 a) || x >= 1/3 (4 + 4 a))) || (1 < a <  2 && (x <= -4 + 4 a || x >= 1/3 (4 + 4 a))) || a >= 2 

I have to rewrite it by hand as

(a <= -2&&True) || (-2 <  a <= -1 && (x <= 1/3 (-4 + 4 a) || x >= 4 + 4 a)) || (-1 < a <=  1 && (x <= 1/3 (-4 + 4 a) || x >= 1/3 (4 + 4 a))) || (1 < a <  2 && (x <= -4 + 4 a || x >= 1/3 (4 + 4 a))) || (a >= 2 &&True) 

and then

Unevaluated[(a <= -2&&True) || (-2 <  a <= -1 && (x <= 1/3 (-4 + 4 a) || x >= 4 + 4 a)) || (-1 < a <=  1 && (x <= 1/3 (-4 + 4 a) || x >= 1/3 (4 + 4 a))) || (1 < a <  2 && (x <= -4 + 4 a || x >= 1/3 (4 + 4 a))) || (a >= 2 &&True)] /. (Or[a_ && b_]) :> {b, a} // Apply[Piecewise[{##}] &] 

Is there a better way?

IIS url rewrite exception

We are hosting some sites on IIS. We have the url rewrite module installed and are rewriting anything that isn't https to https.

Now we come across an issue where for a very specific file we need to turn this rewrite off. But for some reason it doesn't work. It still rewrites to https.

Can anyone see what I am doing wrong?

Thanks.

[​IMG]

Custom Post Type – Category Rewrite – Remove Rewrite from Sitemap

I’ve got “case_studies” post type and categories for it as “case_studies_categories” with a rewrite to include category in URL.

Everything works, but for some reason, rewrite url is in sitemap (as the first URL), for example:

/case-studies/%case_studies_categories%/ 

and the rest is fine:

/case-studies/%case_studies_categories%/ /case-studies/category-name/post-name/ /case-studies/category-name/post-name/ /case-studies/category-name/post-name/ 

How to remove it (/case-studies/%case_studies_categories%/) from Sitemap?

    add_action('init','case_studies_init');  function case_studies_init(){      $  labels = array(         'name'               => _x( 'Case Studies', 'Case Studies' ),         'singular_name'      => _x( 'Case Study', 'Case Study' ),         'add_new'            => _x( 'Add Case Study', 'Case Study' ),         'add_new_item'       => __( 'Add Case Study' ),         'edit_item'          => __( 'Edit Case Study' ),         'new_item'           => __( 'New Case Study' ),         'all_items'          => __( 'All Case Study' ),         'view_item'          => __( 'View Case Study' ),         'search_items'       => __( 'Search Case Study' ),         'not_found'          => __( 'No Case Studies Found' ),         'not_found_in_trash' => __( 'No Case Studies in Trash' ),         'parent_item_colon'  => '',         'menu_name'          => 'Case Studies'     );     $  args = array(         'labels'                => $  labels,         'description'           => 'Holds case studies post data',         'public'                => true,         'menu_position'         => 7,         'hierarchical'          => true,         'menu_icon'             => 'dashicons-admin-comments',         'rewrite'               => array('slug' => 'case-studies/%case_studies_categories%', 'with_front' => false),         'supports'              => array( 'title', 'revisions', 'thumbnail'),         'has_archive'           => true,         'show_ui'               => true,         'show_in_nav_menus'     => true,         'show_in_menu'          => true,         'show_in_admin_bar'     => true,         'taxonomies'            => array("case_study_categories"),     );      register_post_type('case_studies',$  args);   //  flush_rewrite_rules( false ); }  // register a custom category taxonomy type // so that the categories are not connected to the 'post' type taxonomies  add_action( 'init', 'register_case_study_tax' );  function register_case_study_tax(){      $  labels = array(     'name'              => _x( 'Case Study Categories', 'case-studies'),     'singular_name'     => _x( 'Case Study Category', 'testimonials'),     'search_items'      => __( 'Search Case Study Categories'),     'all_items'         => __( 'All Case Study Categories'),     'parent_item'       => __( 'Parent Case Study Category'),     'parent_item_colon' => __( 'Parent Case Study Category:'),     'edit_item'         => __( 'Edit Case Study Category'),     'update_item'       => __( 'Update Case Study Category'),     'add_new_item'      => __( 'Add Case Study Category'),     'new_item_name'     => __( 'New Case Study Category'),     'menu_name'         => __( 'Case Study Categories'),     );      $  args = array(     'labels'                => $  labels,     'taxonomy'              => 'case_study_categories',     'object_type'           => 'case_studies',     'hierarchical'          => true,     'show_ui'               => true,     'show_admin_column'     => true,     'query_var'             => false,     );      register_taxonomy('case_studies_categories', 'case_studies', $  args); }   /** filter URL link for post type url **/ add_filter('post_type_link', 'case_studies_permalink_structure', 10, 4);  function case_studies_permalink_structure($  post_link, $  post, $  leavename, $  sample) {   if ( false !== strpos( $  post_link, '%case_studies_categories%' ) ) {     $  event_type_term = get_the_terms( $  post->ID, 'case_studies_categories' );     if($  event_type_term)     $  post_link = str_replace( '%case_studies_categories%', array_pop( $  event_type_term )->slug, $  post_link );    }  return $  post_link; } 

I’m sure I’ve done something stupid, please assist if possible.

Thanks,

How to configure .htaccess to rewrite all requests into a folder, except a list of exceptions

I have an established website with some legacy folders I would like to keep.

  • https://example.com/.well-known/
  • https://example.com/Music/
  • https://example.com/Rutabagas/

I’ve also installed WordPress. Because there’s an automated update/backup system, I chose to put WordPress into a folder. This way, the WordPress management system won’t see my legacy folders as part of WordPress and wipe them out next time there’s an upgrade.

  • https://example.com/WordPress/

I would like for when anyone visits https://example.com/ to see the WordPress site, without the /WordPress/ part of the URL. No problem, Google has several results on how to do this, except, I still want my list of legacy folders to keep working and the answers I can find only work to redirect everything.

Is there a way to configure .htaccess to rewrite everything into the WordPress folder including /, but not my three or four legacy folders and everything inside, which I want the server to continue handling as normal?

I need to take some XML/SP Services code and rewrite using ajax

I was given this XML code and they would like to convert it into ajax code. I have never worked with XML/SP Services and I am not sure if what I have done is right.

var accID = 'AIRLINES'; var searchVal = ''; $  (document).ready(function () {      tdResults = $  ().SPServices.SPGetListItemsJson({         webURL: "/airport/business",         listName: "TenantDirectory",         viewName: "",         CAMLQuery: "",         CAMLViewFields: "",         CAMLRowLimit: "",         CAMLQueryOptions: "",         changeToken: "",         contains: "",         mapping: {             ows_Title: {                 mappedName: "Title",                 objectType: "Text"             },             ows_Address: {                 mappedName: "Address",                 objectType: "Text"             },             ows_Numbers: {                 mappedName: "Numbers",                 objectType: "Text"             },             ows_Categories: {                 mappedName: "Categories",                 objectType: "Text"             },             ows_link: {                 mappedName: "Link",                 objectType: "Text"             },             ows_ID: {                 mappedName: "ID",                 objectType: "Text"             },          },         mappingOverrides: null,         debug: false     });  
var tdResults = $  .ajax({     url: apiUrl1,     method: 'GET',     headers: {         'Accept': 'application/json; odata=verbose'     },     success: function (data) {          var items = data.d.results;          for (var i = 0; i < items.length; i++) {              var title = items[i].Title;             var address = items[i].Address;             console.log(address)             var number = items[i].Numbers;             var categories = items[i].Categories;             var id = items[i].ID;             var link = items[i].Link;          } // this ends for loop          /*mappingOverrides: null,         debug: false*/      }, // this ends success function      error: function(data) {         console.log('Error: ' + data);     } }); //end of ajax 

Category archive rewrite rule to include category/subcategory?

I’d like to have my category archive (category.php) accessible using via a url structure like:

mysite.com/mycategory/mysubcategory

For example, I’ve got “health” as a category and “smoking” as its subcategory. The following:

  • mysite.com/health
  • mysite.com/smoking
  • (and even) mysite.com/category/health/smoking

all work fine.

But mysite.com/health/smoking gets a 404.

Is there something under Settings->Permalinks that will fix this? Do I need to put a rewrite rule of some kind in functions.php?

Thanks.