Questions tagged [rewrite-rules]

Rewrite rules modify a web URL's appearance. This modification is called URL rewriting. Rewritten URLs (sometimes known as short, fancy URLs, search engine friendly - SEF URLs, or slugs) are used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of abstraction between the files used to generate a web page and the URL that is presented to the outside world.

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

website migration url HTAccess rewrite rule [closed]

I couldn't find any post about my exact problem and I'm not smart enough to try&error things on a live website. So please help. I want to migrate Website A into Website B and I know that I need to ...
  • 1
0 votes
1 answer
13 views

add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico

Please Friend all, help me! How add_rewrite_rule in multisite subdomain from images via functions.php not .htaccess My Image Path https://cdn.domain.com/images/site2/favicon.ico But I want change url ...
0 votes
0 answers
24 views

rewriteRules WP6

I’ve got a custom post type slides which is set up this way function register_slides() { $labels_slides = array( 'name' => __( 'Slides', 'slides' ), 'singular_name' => __( '...
  • 1
0 votes
0 answers
38 views

Standard Regex syntax doesn't work in WordPress rewrite rule

I've run into a regex issue while adding a rewrite rule into a Wordpress plugin. This blog has been helpful and the redirect works correctly after following this: https://brightminded.com/blog/...
  • 141
0 votes
0 answers
47 views

Wordpress rewrite rule - not able to access second and third parameters

I have a rewrite rule; add_rewrite_rule( 'jobs/search/([^/]+)/state/([^/]+)/position/([^/]+)/?$', 'index.php?post_type=job&search=$matches[1]&state=$matches[2]&position=$matches[...
  • 101
1 vote
2 answers
60 views

add_rewrite_rule not working with custom variables

I posted this in stackoverflow as well, so hope it's good to post here as well! I think this is my last problem to solve before everything clicks into place: I have a homepage with a custom plugin ...
3 votes
1 answer
33 views

What is the best way to relate different custom post types?

Let's say I have 3 CPTs: series, seasons, and episodes. Now if I post in these custom post types the URL would be: Series CPT > post name: sample serie > URL: site.com/series/sample-serie ...
0 votes
0 answers
23 views

Two Permalinks with one Taxonomy (custom taxonomy) and (custom post type -> custom taxonomy)

I already readed this thread: "Permalinks: custom post type -> custom taxonomy -> post", but it didn't help me how I want it. I'm having trouble working with WordPress rewrite rules, ...
1 vote
1 answer
29 views

Standard Htaccess directives disappear by themselves

I have an odd issue on one of my websites. I'm talking about the standard, native, url directives put by wordpress, that just plain disappear from time to time, which of course breaks my site. Here is ...
0 votes
1 answer
135 views

'Unsupported Operand Types' error stemming from taxonomy re-writes with PHP 8.1

I was getting a FATAL ERROR in WordPress, but only on the front end. I KNOW the error is within my plugin, but the stack trace returns info about WP Core files, and doesn't identify where in my ...
  • 1,935
0 votes
0 answers
18 views

Change variants URL

When I create a new varaint, a new item will be in wp_posts table and a new row in wp_terms table. What I want to achive is taht if the oroginal product was http://mysite/the-product-name/ and the ...
  • 181
0 votes
0 answers
16 views

Rewrite rule to simulate page hierarchy results in 404

On my WordPress site, I want pages with slugs beginning with outline- or result- to be accessible by requesting URI's that begin with outline/ or result/ instead, as if the pages in question were ...
  • 15
1 vote
0 answers
28 views

Rewrite URLs in a Custom Post Type with Multiple Taxonomies

I'm trying to filter the content of a custom post type, but I can only get it to read the first variable. The custom post type has 3 associated taxonomies that if I pass them through GET in the URL it ...
0 votes
1 answer
170 views

What is the `rewrite_rules` option the options table in the WordPress database?

I'm troubleshooting an issue with permalinks. As part of my troubleshooting, I discovered that this row in the table wp_options is changing: +-----------+---------------+----------------+----------+ | ...
  • 632
0 votes
0 answers
14 views

Same slug for Custom Taxonomy archive and CPT archive - Rewrite rule not working

I’m using a CPT (wg_seo_chat) together with a Custom taxonomy (wg_chat_category). Additional rewrite rules are in place to inject the Taxonomy into the URL: CPT archive: domain/hilfe-chat Taxonomy ...
0 votes
0 answers
22 views

Rewrite rule to index.php in theme subfolder

I'm trying to create a rewrite to an index.php in a subfolder of my theme. But with this code I only end up on the front page: function coupon_query_vars( $query_vars ){ $query_vars[] = 'gutschein'; ...
  • 39
0 votes
1 answer
18 views

Custom archive URL as a subfolder of the custom post type slug

I have a Custom Post Type called Whatever. The slug for this CPT is whatever. By default, I can access the posts archive in the frontend at /whatever and each post at /whatever/post-slug But I would ...
-1 votes
1 answer
33 views

Configuring static page with add_rewrite_rule gives 404 after navigating to Permalinks admin panel

I would like to create a simple static page in my theme which would then show some practical information on a certain event. The page would be served on the path /practical. For now, there are no ...
  • 101
0 votes
0 answers
15 views

url rewrite doesn't load woocommerce product

I have this woocommerce permalink structure: /watches/google/%prod_cat%/ since for each product I have 2 prod_cat (multi language) eg: "1926-fr", "1926-en", I'm trying to display ...
0 votes
1 answer
18 views

Programmatically add a custom url route "/category/index.json" to return a collection of posts in json

I would like to serve a list of posts pertaining to a specific category in JSON format at this endpoint: /category/category-slug/index.json I figured I could, as a start, point to the REST API for the ...
  • 2,787
0 votes
0 answers
15 views

CPT Archive Pagination - Page not found

I have the following code to register my CPT, related taxonomy and rewrite rules. $store_name = 'store' add_action('init', function () use ($store_name) { register_post_type( 'my_sample_cpt', ...
  • 1
0 votes
0 answers
17 views

How to add custom permalink struct with DYNAMIC author to a Custom Post Type

I created a CPT called column. I want to add a custom permalink struct ONLY to this CPT: /columnists/%author%/%postname% I need to pass the author CPT in the link, too. I already set the slug inside ...
  • 101
0 votes
0 answers
16 views

Rewrite rule giving 404 error

We have a large Woocommerce site which is based on roots/sage and roots/bedrock. We have a staging site and a production site which are identical in terms of the theme, plugins and are both hosted on ...
  • 13
1 vote
0 answers
13 views

Wordpress add parameters with friendly url structure

I build a Wordpress website with a page called 'Nieuwsberichten'. The url looks like https://www.example.com/nieuwsberichten This page is dynamic and I need an extra parameter called 'news_page' https:...
  • 11
1 vote
0 answers
27 views

add_rewrite_rule not working in Custom Post Type UI Plugin

I created custom post using Custom Post Type UI Plugin. The post type name was: recruit Now my current URL is: http://wordpress-603.com/?recruit=top I want to change it to http://wordpress-603.com/...
0 votes
0 answers
15 views

Add additional URL variations for a Post

My goal is to have multiple variations of the same URL resolve to the same Post. The Post itself would have some different treatments based on the URL the reader followed to get there. In searching ...
  • 111
0 votes
0 answers
20 views

Use add_rewrite_rule to change subpage url

I use to break my post into several web pages. I would like to use add_rewrite_rule and change the url. Example request url: http://domain.com/foo/2 It would get transformed to http://domain.com/foo-...
0 votes
1 answer
40 views

URL rewrite parameter lost (add_rewrite_rule)

This is definitely not the first question regarding the issue. I have read a lot and tried, even more, but without success. I want to do the following: rewrites URLs from: example.com/cars/lambo to: ...
  • 143
0 votes
0 answers
35 views

Wrong rewrite rules

I have rewrite rules like this 'forum/(.+?)/?$' => 'forum=$matches[1]', 'forum' => 'pagename=forum', website.com/forum -> correct website.com/forum/page/2 -> 404 because it detect ...
1 vote
1 answer
21 views

URL Redirect on GoDaddy platform [closed]

I am the IT support person for one of our clients. We have a domain hosted on GoDaddy in one account pointing to a WordPress site located in another GoDaddy account created by our client. In the DNS ...
0 votes
0 answers
14 views

add_rewrite_rule not working with custom post type

I am trying to follow the examples in the wordpress documentation about add_rewrite_rule and add_rewrite_tag. I'm using a custom post type called "panel". so the pages look like "site....
0 votes
1 answer
24 views

Url rewrite with custom post type and taxonomy

Here is what I am looking for: Custom Post Type: partner Archive: domain.com/partners/ (list all partners) Custom Taxonomy: country Archive: domain.com/partners/denmark/ (list all partners in a ...
0 votes
0 answers
71 views

Add rewrite rule to make Woocommerce product category page seo friendly

I want to show sale products of that particular product category page by using /sale except using a query string stock_status=onsale. e.g https://www.example.com/sneaker/?stock_status=onsale It ...
0 votes
0 answers
16 views

Rewrite rule for query params

I want to rewrite https://www.example.com/sub/0001 to https://www.example.com/sub/?id=0001 matching the id (in this example 0001) I tried with add_rewrite_rule('^sub/([0-9]+)$', 'sub/?id='.$matches[0],...
1 vote
0 answers
40 views

How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT

What I have: example.com/movies/{post} <!-- custom Post Type single post, e.g. /movies/batman --> example.com/genres/{term} <!-- custom Taxonomy single term e.g. /genres/action --> What ...
  • 21
0 votes
1 answer
25 views

Wordpress rewrite rule for specific page and second parametr doesnt work

I have a link like this: https://example.com/page-test/?v=p300 and I created rewrite rule to point new url: https://example.com/page-test/p300/ but it doesnt work. Just there is redirect to correct ...
0 votes
1 answer
158 views

Is it possible to add a site-wide add_rewrite_rule for a multilingual site?

We have a client who has had a brand new site developed by another agency, it is multilingual via some custom fields and some basic logic to display the relevant language via a simple language ...
  • 21
1 vote
1 answer
470 views

Disabling direct access to images using .htaccess

I have installed Wordpress in a subdirectory of a subdomain. I am using the following rewrite rule to direct all urls to this subdirectory. RewriteCond %{HTTP_HOST} ^(www\.)?mysubdomain.mydomain\. ...
  • 13
0 votes
0 answers
20 views

Safest way to create a custom permalink

I'm building a plugin for woocommerce where a user can purchase tickets for participating in a quiz. BTW, the URL of the dev environment I'm building the plugin in is localhost/lottery (keep that info ...
  • 127
0 votes
0 answers
18 views

Wordpress rewrite rule doesn't work unless post category is explicitly called in regex

I'm struggling to understand why WordPress is doing what it's doing in this situation, and I'm hoping someone can explain to me why the rewrite rule doesn't work unless I explicitly call a category ...
0 votes
0 answers
12 views

When request has multiple matching rewrite rules, and matched rule returns 404 - iterate to next rewrite rule

If my pages have multiple rewrite rules, and the first rule matched returns a 404 error, how can I make it so that the next rewrite rule is attempted first before the 404 error is shown
0 votes
0 answers
21 views

Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts

(Edit: Like one of the links below mentioned, it has to do with the order in which the Matching Rule is called, the more engagement/traffic/activity a BP page gets, the more the rewrite rule is called ...
0 votes
1 answer
27 views

Get wordpress installation folder

I'm writing a rewrite rule, accompanied by two additional rewrite tags, which (the tags) must apply only on a specific page. In the past, when I had to do something similar, I had done it like this: ...
  • 127
0 votes
1 answer
26 views

Url Rewriting a dynamic wordpress page with parameters

I am struggling a bit with how to rewrite a WordPress URL. I have two custom post types that I gave these url structures: mysite.com/erika-mustermann/ mysite.com/offer/shoe-repair/?bername=Erika-...
  • 3
0 votes
0 answers
27 views

How to change an existing wordpress page rewrite rule?

I'm new here and I don't have mach coding experience. I've created a new page layout the data there is taken from a text file and the name of the file is passed in a parameter so for example the url ...
  • 1
0 votes
0 answers
20 views

Custom WooCommerce rewrite rules with comma delimiter

I'm trying to troubleshoot a wide-scale problem. I'd like to rewrite default WooCommerce permalinks for categories, to delimiter as commas. Let's take an example: Brand Model Generation Engine ...
  • 1
1 vote
0 answers
117 views

How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?

The URL structure I am hoping for is as follows: All posts: /blog/ and /blog/page/2 Categories: /blog/%category%/ and /blog/%category%/page/2 Post: /blog/%category%/%postname%/ Tags: /blog/%tag%/ and ...
0 votes
1 answer
26 views

Trying to add array of paths to post permalink

Am trying to add custom path to my article posttype so my article path will be www.example/parent-post-1/parent-post-2/the-actual-post i tried to add this code /** * @param $post_link * @param $id *...
0 votes
1 answer
19 views

How to make a post accessible from multiple post type slugs?

I have two custom post types colors shapes I have a post called "red" under the custom post type "colors". The default URL for this post would be example.com/colors/red Now I ...
  • 1
0 votes
0 answers
26 views

How to rewrite URL back to default custom URL if no destination found

My current situation is: I'm redirecting the custom category request to below kind of url: http://my_url/news/category/abc I've managed to add my custom query var category and can get the query var ...
  • 1

1
2 3 4 5
24