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
19 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 ...
user avatar
  • 1
1 vote
1 answer
45 views

How can i redirect one url to another url using .htaccess or add_rewrite_rule

I am stuck at redirecting one url to another url. I want to redirect https://samedomain.com/page-check-927GSJAYS639AL/highlights to https://samedomain.com/page-highlights/ (927GSJAYS639AL this is id ...
user avatar
0 votes
0 answers
7 views

can't install any wp plugins [duplicate]

We recently moved WP hosts. We backed up WP and imported it to a development site wp.mysite.com to get it all set up. Once everything was done, we switched the DNS and went live with newdomain.com on ...
user avatar
  • 101
0 votes
0 answers
14 views

Change permalink structure specific category

I have a specific category that all posts that are in that category must follow the following structure: category-name/child-category-name(if any)/post-name The other posts will remain with the ...
user avatar
0 votes
0 answers
37 views

Creating dynamic content and pages for 1000's of locations

How can I generate dynamic pages on a Wordpress website from information provided in a separate MySQL database? I have a database with Locations and I would like to have a page for each of these ...
user avatar
0 votes
0 answers
13 views

Remove cpt slug from url and use custom taxonomy instead breaks all other cpt

Im trying to do so, it works but also affects all other cpt (404 for all cpt but not resources one) this is what I have In the cpt definition ... 'rewrite' => array( '...
user avatar
0 votes
0 answers
10 views

Remove tag base and category base while still keeping the rewrite rules

In order to have a URL structure with both category and tag combined (xyz.com/category/soccer/without-laces/tag/adidas ) I use the following rewrite rule in functions.php: function ...
user avatar
1 vote
0 answers
10 views

How to add a custom redirect rule for Post as subdomains?

I am trying to write a custom redirect rule to open a download matching pages. Example: postname.example.com/download Example2: postname.es.example.com/download I am using the following code in my ...
user avatar
0 votes
1 answer
22 views

Wordpress add a rewrite rule to a page to accept a GET variable

I want to rewrite mysite.com/events/submission/test-event-01 to mysite.com/events/submission?epl=test-event-01 This is what I have done so far without any result. I get a 404 error (mysite.com/events/...
user avatar
  • 213
0 votes
0 answers
17 views

Remove subcategory slug from url

My posts are sorted by categories and subcategories Their urls look like this : https://one-domain.com/blog/ https://one-domain.com/blog/news/ https://one-domain.com/blog/news/video-games/ https://...
user avatar
0 votes
1 answer
18 views

Access to the template file of a plug-in

I am developing a plugin that consists only of REST API queries. It consists only of the myplugin.php and the template files (index.php, style.css & functions.js) and has no connection to the ...
user avatar
  • 103
0 votes
0 answers
47 views

issue with wordpress [wp-admin] redirects, when using kubernetes ingress hosting two wordpress websites using path

i'm trying to setup a kubernetes deployment for two wordpress websites in different pods, each will have it's own deployment and service, etc..., under the same ingress, i have setup the ingress this ...
user avatar
  • 1
0 votes
1 answer
38 views

URL rewriting in wordpress using parameters

This seems like a fairly simple idea, and forgive me for my ignorance, but in searching and testing various options, none of them work at all. I have tried a number of htaccess ideas and also ...
user avatar
  • 881
0 votes
0 answers
60 views

"/" URLs without trailing slash shows 404

By default any URL on my website will end with a trailing slash. So if I publish a post or page, the URL will end with a "/". But I came across a weird situation where I hit publish but the ...
user avatar
0 votes
0 answers
25 views

Rewrite not working since upgrade to 5.9

I have the following code in my plugin: add_action( 'init', 'hikingchallenges_rewrites_init', 10, 0 ); function hikingchallenges_rewrites_init(){ add_rewrite_rule( 'my-progress/([a-z-]+)[/...
user avatar
  • 1
0 votes
0 answers
19 views

Rewrite Post URL so it is constructed from parent post url & child post url

What I want to achieve: Make Posts (post type 'post') hierarchical (Done - see code below) The child posts should have the following urls: domain.com/parent-slug/child-slug. This is exactly what ...
user avatar
1 vote
1 answer
67 views

Add Rewrite Endpoint to CPT Archive

I have a Custom Post Type with a hierarchical taxonomy archive and want to add an endpoint page called "infopage" to each term in the archive. e.g. domain.com/tax-term-1/infopage or domain....
user avatar
  • 123
0 votes
0 answers
56 views

Adding the amp url prefix to the beginning

I created my own AMP template with this and the URL prefix became 'amp' <?php define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) ); add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );...
user avatar
  • 1
1 vote
1 answer
179 views

Create multiple rewrite endpoints for custom taxonomy archive

I am trying to create custom end point for the custom taxonomy - 'species' I am trying to use urls like https://example.com/dogs/shop/ https://example.com/cats/shop/ https://example.com/dogs/services/...
user avatar
0 votes
1 answer
29 views

Postname on unique permalink structure appends "-2" for a custom post type. How can I get this to stop happening?

I have a custom post type "events" that has rewrites / permalink modification in place so that it includes the year and month in the URL (these come from ACF fields). This works perfectly ...
user avatar
  • 73
0 votes
1 answer
31 views

Custom Post Type posts, conflict with posts after add_rewrite_rule to top

I had cpt with taxonomy like this: add_action('init', 'zsz_add_posttype'); function zsz_add_posttype() { // -- Taxonomy CATEGORIES - [category-a] [category-b] [category-c] [...] ...
user avatar
0 votes
1 answer
17 views

help with custom rewrite rules

I've inherited a site using Code Snippets plugin which has a snippet to rewrite URLs. Unfortunately, I am not a developer so I am unsure what these do. The problem we have is that in the Yoast SEO ...
user avatar
  • 1,660
1 vote
1 answer
133 views

Adding rewrite rule dynamically

I'm trying to dynamically add a rewrite rule that allows one to access any page under an alternate permalink structure of my choosing. So for example, if the alternate permalink structure includes the ...
user avatar
  • 21
0 votes
0 answers
17 views

Rewrite rules - page does not exist

I've made a website for a client for a driver school, and we need to use special plugins connected to a company that handles the database. So from the website, we connect to their database, and load ...
user avatar
  • 1
1 vote
0 answers
67 views

Wordpress shows front page, when it should show 404 with pagination style urls

Whenever I type a url for my site that contains three slashes "/" wordpress shows the front page instead of a 404.For example: example.com/something/does/notexist goes to frontpage, where ...
user avatar
0 votes
0 answers
17 views

corrupted URLs - can't leave starting page

I have a big problem with my WP installation: An access to my pages is (no longer) possible via (public) URL. All calls that originally worked end up on the home page. Also, visitors can't get away ...
user avatar
  • 1
0 votes
0 answers
35 views

.htaccess Rewrite URL WordPress

I have split a URL with JavaScript i have to rewrite it with .htaccess, the issue is that after splitting URL the page takes me to 404 error. I do not have much knowledge of .htaccess, can you help me ...
user avatar
  • 117
0 votes
1 answer
25 views

Use URI suffix as parameter and ignore when resolving page

I'm trying to change the output of pages depending on the URIs last section. This will be used to enable the user to change the page's presentation by changing the URL (e.g. /path/to/page/xml would ...
user avatar
  • 101
0 votes
0 answers
14 views

Rewrite rules for sub category (child product categry & grand-child)

I am lack in rewrite rules. Now I success to rewrite product category parents, but how I rewrite to call child product-category and also for grand-child domain.com/{parent-productCat}/ => success ...
user avatar
0 votes
0 answers
21 views

Rewrite the search page to use an appended slug + parameter

I have two URLs that handle search ~/search/ = main search page ~/?s= = results page What I want: to have one search page where the search parameter for the results page appends to the search page ...
user avatar
  • 101
0 votes
0 answers
24 views

Rewrite wp function

How to Rewrite wp funaction my url is : search-results/?keyword=MBA&group=Program Search-result is the page other is coming for api So can tell me that how can rewrite link this url search-...
user avatar
0 votes
0 answers
12 views

How can I resolve search error with pagination wordpress

I'm using simple pagination from Wordpress and I have problem with the search query. I'm in the archive page (home.php) and when I am on a pagination page and I do a search I get a 404. (example: /...
user avatar
  • 1
0 votes
0 answers
33 views

Custom post type change permalink query

My permalink rules are set to post name. I created a custom post type named: house. The default url would be: {{site_url}}/house/{{house_slug}} Then if I print the query in the pre_get_posts action I ...
user avatar
0 votes
0 answers
35 views

add_rewrite_rule to load different page, without changing URL in browser

I need a function(s) where I load to 1 specific page (index.php?p=49) whenever a URL is written with an all numeric slug/end. However, the written URL has to remain the same in the browser as it ...
user avatar
  • 1
0 votes
0 answers
16 views

rewrite based slug standar post wp

I want to create based slug for default post type wordpress based on query var lang. for lang=en my url want to be https://domain.com/articles/{post-name} for lang=nl my url want to be https://domain....
user avatar
0 votes
0 answers
16 views

wordpress path generation from rewrite rule

I have set a custom rewrite rule. The url gets parsed and loads the correct page. When the same page is added in the menu editor, it does not generates the different path. I want that my same rewrite ...
user avatar
  • 101
0 votes
0 answers
46 views

multiple URLS for the same page

I have an archive page set up for a custom post type, which displays all the posts. When you click on a post, it opens a modal with more information. So as it is now, there is a single url: https://...
user avatar
0 votes
1 answer
18 views

How to allow WordPress to recognize a custom URL segment after a product URL and use a custom template?

Essentially I'm trying to allow a URL like this: https://example.com/products/my-product/test I'm using WooCommerce, my product base is /products, and the product name would be My Product here. I want ...
user avatar
0 votes
1 answer
17 views

Rewrite with pagination /foo/page/2/ to posts of a given category, page 2

This add_action('init', function() { add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top'); }); works and allows example.com/foo/ to display all the posts from category1. But then ...
user avatar
  • 77
0 votes
1 answer
28 views

How to grab query string from wp-content/uploads/.*

I've written a quick little plugin to grab some custom query_vars, do some manipulation, and store the output in a CSV file. It works great for pages and posts, but ... it seems that queries to wp-...
user avatar
1 vote
0 answers
16 views

How to preserve the query string while using add_rewrite_rule and default public query vars

I have a single page application embedded in a WordPress website. I'm able to redirect back to that page with a rewrite that matches the page slug as a base: add_rewrite_rule( '^showroom/?', 'index....
user avatar
  • 11
0 votes
0 answers
20 views

Custom route and extract data from slashes and parameter

some external website is going to send a specific data into a WordPress site and need to extract and process it. The data is coming trough URL (between slashes and as parameter): domain.com/login_sso/...
user avatar
0 votes
0 answers
26 views

Rewrite URL for CPT to domain/post-name/post-id

I am struggling with the rewrite function from Wordpress. I have a custom post type named "catalog". Every post has the permalink domain/post-type/post-name and I will change this to domain/...
user avatar
  • 17
1 vote
0 answers
148 views

What to write in the htaccess in order to detect browser language and point accordingly?

On short: I use Polylang plugin for my web but it's option to detect browser language won't work because I need to use cache in the whole site, including the homepage. I have a bilingual website (...
user avatar
  • 33
0 votes
0 answers
15 views

Is it possible to change redirect template through a shortcode?

I have added a redirect for my plugin in init: add_rewrite_rule( 'city/([a-zA-Z]+)/?$', 'wp-content/plugins/csv-to-html/templates/csvtohtmlpage_core.php?city=$1' ); When I go to <site>/city/...
user avatar
0 votes
1 answer
25 views

Relationship between set rewrite flag in register_post_type and add_rewrite_rule

In register_post_type, I can register a custom post type and set parameters, including rewrite. Based on https://developer.wordpress.org/reference/functions/register_post_type/#rewrite, if it set to ...
user avatar
  • 41
0 votes
1 answer
40 views

Order of rewrite rules when calling add_rewrite_rule

I am checking the document for add_rewrite_rule at https://developer.wordpress.org/reference/functions/add_rewrite_rule/, based on its description, it said "Any value in the $after parameter that ...
user avatar
  • 41
0 votes
0 answers
38 views

add_rewrite_rule() issue with parent/child/child page

I have a parent/child and another parent/child/child pages. I have 2 separate page templates for both pages and the following add_rewrite_rule() code in place: add_rewrite_rule( '^user/dashboard/([^/]*...
user avatar
  • 101
0 votes
0 answers
20 views

Custom Post Type add_rewrite_rule

I have a small detail in a wordpress site, I would like to modify the url of the sinlge post of a specific type of content: post-type = book Current permalink = site.com/book/title-book I want to ...
user avatar
1 vote
1 answer
75 views

Can I write 'RewriteCond' using 'functions.php'?

I want to add 'rewrite condition' in .htcaccess but unfortunately I don't have access of that. Can I write conditions in functions.php ? If yes, how to achieve that ? I want to add these lines: ...
user avatar
  • 39

1
2 3 4 5
23