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
12 views

Taxonomy archives based on Custom Post Types

I have the custom post types, reception_units, year_1_units, year_2_units, year_3_units, year_4_units, year_5_units, year_6_units and resources. I want to create archives for the different post types ...
Sam's user avatar
  • 1
0 votes
0 answers
28 views

Custom post permalinks for specific categories

I have specific categories posts where i want to remove category name from URL. My current post link is: https://example.com/my_cat_name/post_name/ I want: https://example.com/post_name/ But only for ...
DevLoper's user avatar
0 votes
0 answers
42 views

Is there a way to use rewrite rules in Wordpress to correctly render a page or post?

I made a Wordpress plugin that was able to rewrite URLs so that users could add a vanity segment at the end of the URL so that every page had personalized information via an external API call with the ...
Zach Evans's user avatar
0 votes
0 answers
17 views

how to properly format custom post type rewrite to get specific URL structure for archive and post views

The goal I created a custom post type for events listing and want to achieve the following URL structures all archives url This url returns 404 error https://example.com/events-list/ single archive ...
Nadal's user avatar
  • 89
0 votes
0 answers
25 views

Preserve the url for subpage

I have a units page abc.com/units When I visit abc.com/units/toronto this shows a 404 page. I want to preserve the url /units/* and basically just redirect to units page while maintaining the url So,...
grungebobber's user avatar
0 votes
0 answers
22 views

Redirect domain and subdomain to rewrited rule depending on $_SERVER['REMOTE_ADDR']

In first question : Must or do I have to use .htaccess rather than wp redirect ? I’m loolink for to use wp_redirect() to redirect website to new permalink structure for language. Is it the good ...
imagIne's user avatar
  • 41
0 votes
0 answers
23 views

Rewrite rules are chosen inconsistently

I am trying to get some rewrite rules working with Polylang and I'm using the Rewrite Rules Inspector plugin to inspect the rules. Different rules are applying in different environment: my local ...
Dylan's user avatar
  • 113
0 votes
0 answers
25 views

Nesting add_rewrite_rule() with custom page and subcategories

The url structure looking for is : blog/category/subcategory/ blog/category/post/ blog/category/subcategory/post/ My rewrite rules : add_rewrite_rule( 'blog/([^/]+)/([^/]+)/?$', 'index.php?...
karolx's user avatar
  • 1
0 votes
1 answer
25 views

openlitespeed rewrite rules conversion from apache

# BEGIN Wordpress <IfModule mod_rewrite.c> RewriteEngine on # behind proxy RewriteCond %{HTTP:X-FORWARDED-PROTO} ^http$ RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] # plain RewriteCond %{...
WsArea's user avatar
  • 1
0 votes
2 answers
21 views

rewrite for subpage seems to loose parameter

I have defined a rewrite rule for a subpage 'vehiculo' (which is a template-page in my theme folder), and subpage of 'vehiculos', because I want a pretty URL and the code is handled in the template ...
Canelo Digital's user avatar
0 votes
0 answers
9 views

WordPress Custom rewrite does not work with seo url

I try to generate 3 custom rewrite rule, it does not really work very well. Here is my plugin class file. <?php class QuestionAndAnswers { public $isUserLoggedIn; public function ...
Fatih Toprak's user avatar
0 votes
0 answers
19 views

How do I defeat the default action of a query variable on home page redirects to posts page

I am using a query variable to pass some information around the site. It works fine, except that Wordpress is operating some rewrite in the background. In particular, on the (static) home page adding ...
Chris Pink's user avatar
0 votes
1 answer
93 views

How to set product category base the same as shop base in WooCommerce?

I'm using WooCommerce on a WordPress. I would like my products and product categories to have the same url base. E.g. www.example.com/shop/product-category www.example.com/shop/sample-product Using ...
Paweł's user avatar
  • 1
1 vote
2 answers
88 views

Two taxonomies with the same slug

There is a custom post type "real estate" with the slug "sale" and 2 taxonomies city and property type. It is necessary that taxes are displayed refer to the same slug, that is ...
aprinciple's user avatar
0 votes
0 answers
17 views

How to combine nearly identical custom rewrite rules for WordPress

I have 22 rewrite rules in my functions.php. I was wondering if it is possible to combine some of the nearly identical rewrite rules. Combining identical rewrite rules for different PAGES: '^videos/...
Philip's user avatar
  • 103
0 votes
1 answer
25 views

Search pagination rewrite to fix 404

I'm wondering if anyone can help me out here? Basically, I think I need to use add_rewrite_rule() to get pagination working in my search results, as I've gone beyond the default query due to a bunch ...
Jase Warner's user avatar
0 votes
1 answer
31 views

wordpress category rewrite rule with pagination

with the help of someone here I was able to filter two or more categories via this rewrite rule '^combine/([^/]*)/?([^/]*)/([^/]*)/?','index.php?category_name=$matches[1]+$matches[2]+$matches[3]', '...
inrob's user avatar
  • 103
0 votes
0 answers
11 views

make a new structure tag that does some processing

my goal is to have short urls. I'm trying to use base_convert so that "site.com/p=10000" becomes "site.com/7ps" My code is such a mess I don't even think it would be helpful to ...
Scot Nery's user avatar
  • 101
1 vote
1 answer
38 views

Custom URL Rewrite Rules not working

I added the following custom routes to WordPress: function add_custom_rewrite_rules() { add_rewrite_rule( 'generate/?', 'index.php?custom_route=generate', 'top' ); add_rewrite_rule( 'random/?',...
Álvaro Franz's user avatar
0 votes
2 answers
41 views

Wordpress picks a wrong template if ?cat= is used as URL parameter

I have a website with the following article structure. This works and uses archive.php template like it's supposed to website.com/category/articles/arrester/?tag=online-lectures This also works and ...
Natalia's user avatar
  • 131
0 votes
0 answers
42 views

WP-Include rewrite directory

I try few day to rewrite wp-include directory but not success. In .htaccess I add next line <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^main/(.+) /wp-includes/$1 [L,...
kuribo's user avatar
  • 1
0 votes
0 answers
21 views

add_rewrite_rule doesn't work when trying to add a new parameter at the end of URL

I wish to add a userq parameter at the end of a URL with the username such as john. I wish to change, example.com/user/john to, example.com/user/index.php?userq=john I tried this and this and they ...
ratib90486's user avatar
0 votes
1 answer
144 views

Dynamic WordPress rewrite rules for multiple custom post types

I'm very new to WordPress development and would like some pointers if this is possible. So I have this rewrite rule for my custom sidebar in functions.php: add_action('init', 'cpt_rewrite'); function ...
yuki-chan's user avatar
0 votes
0 answers
51 views

Direct domain alias to a specific WordPress page without the page in the URL

I have client with an existing website on domainA.com. They want to use another domain (domainB.com) for some marketing of a specific product that is detailed on a page of their existing website. So I ...
mike_temby's user avatar
0 votes
1 answer
41 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 ...
Muhammad Hasan Bahtiar's user avatar
0 votes
0 answers
25 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' => __( '...
Pitt's user avatar
  • 1
0 votes
0 answers
101 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/...
AutoBaker's user avatar
  • 151
0 votes
0 answers
50 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[...
PavKR's user avatar
  • 101
1 vote
2 answers
662 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 ...
johnbell's user avatar
3 votes
1 answer
45 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 ...
Mr Mousio's user avatar
0 votes
0 answers
27 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, ...
dejonda's user avatar
1 vote
1 answer
37 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 ...
Bucheron's user avatar
0 votes
1 answer
706 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 ...
Tony Djukic's user avatar
  • 1,968
0 votes
0 answers
36 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 ...
vaso123's user avatar
  • 181
0 votes
0 answers
26 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 ...
G.S.'s user avatar
  • 15
1 vote
0 answers
38 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 ...
Carlos Polo's user avatar
0 votes
1 answer
1k 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: +-----------+---------------+----------------+----------+ | ...
Flimm's user avatar
  • 674
0 votes
0 answers
20 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 ...
locke85's user avatar
0 votes
1 answer
88 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 ...
Álvaro Franz's user avatar
-1 votes
1 answer
73 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 ...
gleerman's user avatar
  • 101
0 votes
1 answer
131 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 ...
pixeline's user avatar
  • 2,837
0 votes
0 answers
18 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', ...
Anand's user avatar
  • 1
1 vote
0 answers
30 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:...
Ruudje's user avatar
  • 11
1 vote
0 answers
66 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/...
クジェー's user avatar
0 votes
1 answer
81 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: ...
hbit's user avatar
  • 210
1 vote
1 answer
27 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 ...
Jerry Welliver's user avatar
0 votes
1 answer
33 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 ...
Vayu Robins's user avatar
1 vote
0 answers
143 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 ...
dubyaD's user avatar
  • 21
0 votes
1 answer
72 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 ...
Macsurf's user avatar
0 votes
1 answer
343 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 ...
JMD's user avatar
  • 121

1
2 3 4 5
24