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
6 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
17 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
10 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
12 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
25 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
10 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
13 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 ...
  • 11
0 votes
1 answer
24 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
36 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
105 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
16 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 ...
  • 123
0 votes
0 answers
16 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
8 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
16 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: ...
  • 123
0 votes
1 answer
24 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-...
  • 1
0 votes
0 answers
26 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
18 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
49 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
15 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
16 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
21 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 vote
1 answer
62 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 ...
0 votes
0 answers
8 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 ...
  • 101
0 votes
0 answers
24 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 ...
0 votes
0 answers
52 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 ...
0 votes
0 answers
20 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( '...
1 vote
0 answers
12 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 ...
0 votes
1 answer
25 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/...
  • 213
0 votes
0 answers
29 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://...
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 ...
  • 103
0 votes
0 answers
104 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 ...
  • 1
0 votes
1 answer
39 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 ...
0 votes
0 answers
126 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 ...
0 votes
0 answers
34 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-]+)[/...
  • 1
0 votes
0 answers
36 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 ...
1 vote
1 answer
144 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....
  • 123
0 votes
0 answers
74 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 );...
  • 1
1 vote
1 answer
206 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/...
0 votes
1 answer
30 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 ...
  • 73
0 votes
1 answer
50 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] [...] ...
0 votes
1 answer
21 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 ...
  • 1,588
1 vote
1 answer
253 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 ...
  • 21
0 votes
0 answers
21 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 ...
  • 1
1 vote
0 answers
69 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 ...
0 votes
0 answers
18 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 ...
  • 1
0 votes
0 answers
42 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 ...
  • 149
0 votes
1 answer
26 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 ...
  • 101
0 votes
0 answers
16 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 ...
0 votes
0 answers
29 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 ...
  • 101

1
2 3 4 5
24