rewrite rule generated with mpdf to a shorter version

ok it was easy, the problem was that to match the left side pattern you have to use $1 not $matches[1], this is the solution /** * Rewrite rules */ add_action( ‘init’, function() { add_rewrite_rule( ‘^invoice_([0-9]+).pdf$’, ‘/wp-content/themes/mysitetheme/invoices/invoice_$1.pdf’, ‘top’ ); } ); UPDATE From the suggestions received in the comments, it is now clear to me … Read more

How to redirect Webp files?

If I’m reading it right, your regex has only two items in (), which means that only $1 and $2 have any meaning. I copied your sample text and went to https://regex101.com/ (note: this is not an endorsement) to try to assemble a regex that’ll cover all your images. Here’s what I ended up with: … Read more

Bilingual WP site: How to achieve different URL sturcture rule based on its language?

Try the following steps: Add the rewrite rules for the <language>/blog/%category%/%post_id% structure. I used the post_rewrite_rules hook to add the rewrite rules, but for generating the rewrite rules, I used WP_Rewrite::generate_rewrite_rules() the same way WordPress core used it to generate the rewrite rules for the default permalink structure (that you set via the Permalink Settings … Read more

Get wordpress installation folder

You don’t need to do this. As long as your site URL in Settings is set to mydomain.tld/wordpress you don’t need to include /wordpress in your rewrite rules. If you look at the rewrite_rules option in the wp_options table you’ll see that none of the default rules are using it, because it’s not required.

How can i ensure that SQL statements are not displayed if an enduser types the wrong variable name in the URL

There’s two separate problems here: You have code that causes an error. That error is exposing information to end users that you don’t want to expose. The problem that’s causing #2 is that you have error printing enabled in a production environment, which is against best practice. Error reporting is controlled by a PHP configuration … Read more

My bbPress rewrite rules aren’t working

The problem here is that the rewrite rule uses an invalid regular expression. It’s important to run your rewrite rules through a rewrite rule testing plugin to check that it actually matches the URL you want to use. You don’t need to guess the result then refresh on the frontend to test that it works … Read more

Url rewrite with htaccess

Your first order of business should be updating the links in your imported content so that people aren’t given links to the old URLs in the first place. This should be pretty easy to do with an SQL replace. For your situation, it’d be something along the lines of: UPDATE wp_posts SET post_content = REPLACE(post_content, … Read more

Help with a custom rewrite

Your best bet is to use the WordPress rewrite API. No .htaccess required. First, hook into init and add a rewrite endpoint to your permalinks. This tells WordPress that whens some visits /category/post-slug/gallery match the new endpoint rewrite. it also takes care of adding the query variable for you so you don’t have to do … Read more

Flushing rewrite rules

What flush_rewrite_rules(); does is call $wp_rewrite->flush_rules(); (Also called when updating permalinks). All plugins rewrite rules are regenerated then, so you dont need to worry about other plugins rules being “missing”. Also is not a good idea to call this function (flush_rewrite_rule) on hooks that run each time wordpress is loaded, and is enough to call … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)