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.

Rewrite rule to load images from production makes no difference

I’m trying to adapt the rewrite rule given in Develop Locally, Use Images from Production to do the very same thing on my local dev site (which runs on XAMPP).

This is how the development site’s .htaccess looks, with the snippet added towards the end of it (URL replaced with example.com equivalent, obviously):

<IfModule mod_php.c> php_value upload_max_filesize 64M php_value post_max_size 64M php_value max_execution_time 300 php_value max_input_time 300 </IfModule>  #START WORDPRESS  <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wordpress/  # Redirect About and Library to first sub page  RewriteRule ^about/?$   /wordpress/about/history/ [L,NC,R=301] RewriteRule ^the-library/?$   /wordpress/the-library/gallery/ [L,NC,R=301]  RewriteRule ^index\.php$   - [L]  RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L]  # If images not found on development site, load from production  RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$   RewriteRule ^(.*)$   https://www.example.com/$  1 [QSA,L] </IfModule>  #END WORDPRESS 

The rewrite rule doesn’t seem to be making a difference, whether with the HTTPS or HTTP version of the URL. Images unavailable for the dev site simply don’t display, even when the same images load fine for the production site.

I also had no luck trying to adapt the rewrite rule found in this slightly different question applying to WordPress Multisite.

Additionally, I previously added a filter to stop WordPress from modifying the .htaccess file, so am pretty sure that this isn’t the cause of the problem.

What, if anything, is wrong with my rewrite rule here that’s causing it to fail?

Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts

I’m a self-taught programmer with a very little experience in WordPress programming. I’m using a post permalink structure in this way:

https://domain.com/parent-category/child-category/post-title-here/

I want to have the possibility to optionally have URLs with two “parameters”, “routes”, “deepth-levels” like this:

https://domain.com/parent-category/child-category/post-title-here/john-doe/light-blue/

With APACHE’s mod_rewrite I know I can “convert” a URL like: https://domain.com/index.php?name=john-doe&color=light-blue in some like: https://domain.com/john-doe/light-blue/

But, in WordPress, how can I do this without messing all the other URLs and routing process-flow? My goal is read the GET params name and color in the functions.php file so I can make some code with that.

EDIT:

I think that a mod_rewrite rule for “converting” / accepting URLs like this https://domain.com/parent-category/child-category/post-title-here/?name=john&color=light-blue in something like this https://domain.com/parent-category/child-category/post-title-here/john-doe/light-blue/ would do the trick! Using add_rewrite_url()

Thanks for reading.

ip6tables rule equivalent for iptables DADDR option to rewrite destination address

When i try to run the following ip6tables command on the Ubuntu 16.04 LTS version of Linux, it shows an error saying the option DADDR --set-addr is an unknown option

sudo ip6tables -t mangle -A INPUT -m dscp --dscp 11 -j DADDR --set-daddr=<ipv6_addr> 

ip6tables v1.6.0: unknown option “–set-daddr=”

Is there an option in ip6tables to rewrite the Destination IPv6 address for PREROUTING chain?

Ubuntu Details

Distributor ID: Ubuntu Description:    Ubuntu 16.04.6 LTS Release:    16.04 Codename:   xenial 

How to rewrite https://www.example.com/post-new/ to https://www example com/gadget/post-new/

On a custom post type, my url sample was https://www.example.com/post/.

Now I have added amp, so I want to rewrite the custom post url from https://www.example.com/post/ to https://www.example.com/gadget/post/

That is, I want /gadget/ to come in the url like above. I already done this, but the challenge is old url does not redirect to new url structure

Can anyone guide me please….?