Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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

Display A Post At A URL without Redirecting

I want to have a single post show up for multiple URLs. The post would be at "category/post-name/" and I want all URLs like "category/post-name/asdfa" to show the post, but keep ...
Sarah's user avatar
  • 1
1 vote
0 answers
10 views

How to Dynamically Change the author_base URL Slug by Language in WordPress?

I am working on a multilingual WordPress site using WPML and I am trying to adjust the author_base URL slug based on the user's language. My goal is to have different slugs for each supported language ...
Robin Martijn's user avatar
0 votes
2 answers
23 views

Is there a way to create a single rewrite rule to handle multiple variables depending on what is present?

I have the following rewrite rule to handle when all arguments are present: add_action('init', 'ebd_custom_rewrite_rules'); function ebd_custom_rewrite_rules() { add_rewrite_rule('^shop-region/(.*)...
Tommizzy's user avatar
1 vote
1 answer
24 views

How to add random prefix (based on related page slug) to custom post type?

I want to create some specific url structure for my website. My Pages will be Inner Home pages that will combine articles and reviews. Articles and reviews are 2 separate custom post types. I would ...
Oleksiy Goldayev's user avatar
0 votes
0 answers
15 views

Get URL parameters with rewrite rules

We have some rewrite rules and would like to get the url parameters on that pages/feeds. That does work on regular feeds, but not on those with a rewrite rule. On regular feeds like https://domain.com/...
wepli23's user avatar
1 vote
1 answer
13 views

How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?

I want clean URLs without a custom taxonomy name or custom post name. The project and its structure are somewhat complex. The customer wants certain strings from a third party plugin to be removed ...
Rick Pestel's user avatar
0 votes
1 answer
12 views

`query_var` values empty in theme file after `add_rewrite_rule` redirection

I am redirecting a specific url format using add_rewrite_rule after adding an additional query_var (mlang) to it. Example: http://localhost/periodicals/sri-bn is to be redirected to http://localhost/...
sariDon's user avatar
  • 265
1 vote
2 answers
47 views

Rewrite taxonomy permalink appended to CPT archive url

I need the following url structures for my Custom Posttype and Custom Taxonomy. Can anyone please help in achieving them? Spent a lot of time but failed. Ton of thanks in advance. Post URL: https://...
TechieBoy's user avatar
0 votes
1 answer
23 views

Is it possible to use the same slug structure for a taxonomy and for some pages?

I have a taxonomy project_category, and I want the URLs to appear as: https://www.example.com/{$term_slug}-web-design/ I can achieve this with rewrite rules, but the problem I'm running in to is that ...
JacobTheDev's user avatar
  • 1,231
0 votes
0 answers
20 views

Adding Category to Child Posts Permalink

I'm attempting to add a category of each child post to that post's permalink. The post type is called lessons. I have a taxonomy called Child Categories that contains the terms workbooks and workbook-...
Felicia Santos's user avatar
0 votes
0 answers
61 views

Cannot use dynamic prefix for WooCommerce permalink

I need to use a dynamic permalink structure for WooCommerce products, basically, the structure I'm trying to achieve is the following: /<dynamic>/post_name. So what I did is create a rewrite tag:...
sfarzoso's user avatar
0 votes
0 answers
16 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
32 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
67 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
18 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
28 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
28 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
  • 83
0 votes
0 answers
29 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
28 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
46 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
36 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
14 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
23 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
146 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
131 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
1 answer
41 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
51 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
1 vote
1 answer
45 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
59 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
61 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
26 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
218 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
1 answer
49 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
27 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
125 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
1k 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
70 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
1 vote
1 answer
51 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
1k 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
  • 2,108
0 votes
0 answers
27 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
39 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
2 answers
2k 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
  • 683
0 votes
1 answer
133 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
98 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
163 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,857
0 votes
0 answers
21 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
37 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
  • 21
1 vote
0 answers
74 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
98 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
  • 230

1
2 3 4 5
24