Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 ...

0
votes
1answer
9 views

Help adding custom url, rewrite_rules_array

I'm trying to get a rewrite_rules_array rule to work and running into issues. I would like to add a rule so that when someone visits: http://domain.com/product/foo/bar It essentially loads: ...
0
votes
2answers
30 views

URL rewrite problem in WordPress plugin

I am having some trouble getting rewrite rules to work as I want in my a WordPress plugin. I added a rewrite rule: add_rewrite_rule('some_url','some_redirected_url', 'top'); The rule is written to ....
0
votes
0answers
9 views

Custom post type parent page exclude sub pages

OK I will try to explain as best as I can. I have a wordpress site with the following page structure. /parent/sub-page-1/ What I want to do is attach a custom post type to the parent page which I ...
1
vote
1answer
11 views

add_rewrite_rule ignoring other params than the “p” param

A specific post on my website has a shortcode that uses a parameter called "query" to produce its content. So, this is an example of a working URL: https://example.com/my-post?query=980 "my-post" is ...
0
votes
1answer
32 views

Associate the “add_rewrite_endpoint” and “$_GET”

I have an i18n class. The class find lang tag. For example: "?lang=en" And i want it work with subdir. For example: eg.com/en and eg.com/hello-world/en For this i am using: add_rewrite_endpoint ...
0
votes
0answers
25 views

custom rewrite rules will not be added to wordpress rewrite_rules database

I want to make rewrite. this is my rewrite code: function coinDedicatePage_rewrite() { global $wp_rewrite; add_rewrite_tag('%coinName%', '([^&]+)'); add_rewrite_rule('^coin/(.+?)/?$...
-1
votes
0answers
11 views

WordPress Rewrite Rules Causing JavaScript to Not Load

After rewriting URLs for specific page requests, JavaScript is not loading on the pages. There are no 400 errors creating any reason to believe that the paths are being rewritten, but Modernizr is ...
0
votes
1answer
28 views

Trouble with question mark in rewrite rule

The url I am trying to rewrite looks like this. root_domain/something/something-else/also-different-1030/?success=1289 With this rewrite rule I am trying to catch the url and direct it to the post ...
0
votes
1answer
27 views

rewrite rules problem with #comments-2345

I am trying to created new rewrite rules for sth like this www.myweb.com/question/#comments-2345 where 'question' is TAG and the #comments-2345 suppose to be recognized and read by get_query_var. '#...
0
votes
0answers
15 views

Rewrite Rules and redirecting problem

I have this code which works fine for another users environment but not my environment. Tried to flush cache, flush rewrite rules etc.. The page just redirects either to the homepage or to the ...
0
votes
1answer
24 views

Custom WordPress Pages

Recently, I have started developing a WordPress Events plugin as none of the off-the-shelf ones met the specific criteria for this project. I have ended up creating a few database tables for tracking ...
0
votes
0answers
25 views

How to inject dynamic parameters into url pathinfo for all site content

Similar to this question here, but modified for my purposes: I want to inject into all urls of my website a country. For example: https://www.example.com/contact should be accessible by https://www....
0
votes
0answers
25 views

Specific permalink structure for a category posts

This similar question has asked & answer before. But the given answer throwing me 404. First I would like to check this question first - Give specific category its own permalink structure I am in ...
0
votes
0answers
21 views

How create url rewrite for 3 different taxonomies in the same Custom Post Type

Hello I have a custom post type called "vehicles_cpt" to this are linked 3 taxonomias (year, make, model) I need to write a url like this https://localhost/2019/volvo/x7 redirect to the post that has ...
2
votes
1answer
38 views

Flush Rewrite Rules on init or rest_api_init?

if I'm using the REST API to create endpoints in my plugin, should I be flushing rewrite rules on init or in rest_api_init? I realize that it should be done on plugin activation/deactivation. However,...
1
vote
0answers
45 views

Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page

I'm migrating a site between hosts and am having issues with what should be(!) a fairly simple rewrite of a "pretty" URL to display posts filtered by category. domain.xyz/category/cat_name/ => ...
1
vote
0answers
19 views

Use “search” in permalink?

I am currently in the process of migrating a custom web app to WordPress and in the custom app, search requests have a URL structure of mydomain.com/search?q={search criteria}. I attempted to add ...
0
votes
1answer
98 views

Custom rewrite for product variation not working

I'm trying to rewrite the product variation url for a Phone Model attribute for example to this url: index.php?product=example&attribute_pa_model=iphone-x This works when I open it in the ...
1
vote
0answers
32 views

Plugin action rewrite rule - non_wp_rules

The wp rewrite rule I added to my plugin is not working. Here's my setup: Scenario I'm trying to get the site's ads.txt to pull from my plugin's ads.txt. eg site.com/ads.txt pulls from wp-content/...
0
votes
0answers
23 views

Why is there a 404 on page 2+ for my search page?

I've overridden the search.php template from within a plugin, and I've replaced the global $wp_query with a different one, and without any paging parameters it works fine. Once I add a /page/2/ on ...
0
votes
0answers
20 views

WordPress Rewrite Rule to EITHER Match 1 or 2 Taxonomies when adding to URL

I have a custom post type residential using a custom taxonomy residential_taxonomies and I am adding the taxonomy term(s) and the post type name to the url. It works fine if there are always a parent ...
0
votes
0answers
31 views

Rewrite post name / post title in the permalink

I have the following permalink structure: http://test.com/people/kids/joe-blogs/ I need to rewrite the post name (joe-bloggs) to a unique ID to protect the kids names - I have the following ...
1
vote
1answer
62 views

Add rewrite rule to call front-page.php?

I am trying to create a multilanguage website. And I have set my home page to a static page in my WP admin area. This home page ID is 2 and it calls front-page.php template when I am on the home page ...
0
votes
1answer
29 views

Is it possible to register a new template file?

I'm trying to create a custom user dashboard on the front end using a rewrite rule to /dashboard/ and a custom theme file dashboard.php. I notice that when loading in dashboard.php, I have to manually ...
0
votes
0answers
19 views

Would like to customize or remove _wpnonce globally

I see that there's an htaccess rule but I am unsure how to apply it to multiple pages or globally : RewriteRule ^logout/(.*) /wp-login.php?action=logout&_wpnonce=$1 Im using this as a reference ...
0
votes
0answers
56 views

Manage add_rewrite_rule for woocommerce product single page

I am working on WooCommerce single product post, and I wish to add that post meta at the end of product URL. Like I am managing "product_type" post meta for every product and I want to add this at ...
0
votes
1answer
24 views

URL rewrite with external JSON query

I wrote a plugin that can fetch data from an external JSON source and displays a very few details in a list. Each item is clickable to be displayed with more details on a specific template. To do this,...
0
votes
0answers
10 views

Overcoming a complex WordPress page rewrite rules request

Desired URL structure: http://example.com/tips - page http://example.com/tips/post - CPT http://example.com/tips/category - custom taxonomy with hierarchy - parent http://example.com/tips/category/...
-1
votes
1answer
24 views

rewrite rule on plugin activation

I Have Developed a plugin. And I created a rewrite rule manually in .htaccess file. RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(\w+)$ ./...
0
votes
0answers
16 views

Paginate links repeating value in links

I would like the pagination of a certain page to look like this: site.com/page-name/page/2/paged2/1 so I used this: <?php global $wp_rewrite, $wp_query_videos; $wp_query->query_vars['paged'] ...
2
votes
1answer
35 views

RedirectMatch and Redirect interfering with each other

I have the following lines in my .htaccess (there are other lines but these two are next to each other) RedirectMatch 301 ^/datingstories https://example.com/blog/category/relationships/...
2
votes
1answer
32 views

Difficulty with rewrite rules

I can't work out how to combine a rewrite rule and a custom query var. I have created a custom 'edition' template, which calls an external API to populate a table with details of a particular book. ...
0
votes
0answers
18 views

Wordpress rewrite rule remove duplicates

I have a multiple custom post types, one of them being countries and another being activities. I made some URL rewriting so as to change to url to country/activity. It works but now I have the old url ...
1
vote
0answers
32 views

Problem with dinamic add_rewrite_rule()

today i am trying to make a plugin for wordpress that allow change the url of a post to whatever you want, i am added a new custom field called post_permalink_replace in that custom field the user ...
1
vote
1answer
216 views

How to do Basic URL Rewrite Without Redirecting

If I use the simple code below: function my_custom_rewrite_rules() { add_rewrite_rule( '^rewriteme$', 'index.php?page_id=1', 'top' ); } add_action('init', '...
0
votes
0answers
30 views

Remove subdirectory from links

I have installed wordpress in the subdirectory "sub". I need the same content been accessed from the root and also from the subdirectory "sub". So I have created the following rewriting rules and ...
0
votes
1answer
30 views

Add_rewrite_rule doesn't add custom url in plugin

I'm trying to add a couple of custom urls in my plugin. However, it keeps showing 404 Not Found when I access them. I'm not sure what I've done wrong here. Can somebody show me to the right ...
0
votes
2answers
39 views

Add a permalink variable onto custom post type URL after post name slug

I have a custom post type mycpt and I'm trying to allow for a variable to be appended onto the end of the URL right after the post name slug, like this: www.site.com/mycpt/the-name-of-my-post/var-...
0
votes
0answers
27 views

Using meta_key & meta_value in add_rewrite_rule

as a plus to my question here: Multiple Permalinks for custom post type post I have an additional question. I make a new question because the old one is answered correctly. My Code is the following: ...
0
votes
1answer
18 views

Create custom url which executes code (not render render a Wordpress entity)?

I am looking to be able to create a url, which when matched will execute some PHP code and output the result. Can this be done? I'm familiar with rewrite_rules_array, which lets you create custom url ...
1
vote
0answers
17 views

custom rewrite rule help! Custom rewrite rules not applying to custom post type

I'm trying to setup custom rewrite rules and display custom fields the url. I have set it up correctly for the post type 'things to do' with the custom field is displaying. However, when I try adding '...
0
votes
0answers
13 views

Rewrite post type into a page with year filter

I managed to put the posts of a post type 'whatsnew-list' into a page template. However, if I put the year and the end of the url it shows 404.(www.example.com/mypage/2018). How can I filter posts by ...
1
vote
1answer
77 views

URL without www redirect directly with submission page - Multiwordpress install

This is a Wordpress related question, because the problem came from a multi-install Wordpress. But it's also related to serverside, with .htaccess My problem is : when a user type my URL without WWW, ...
0
votes
0answers
17 views

Strange behavior on rewrite_rules

I'm having a strange problem that I'm trying to solve since yesterday. I have a website that has a page called Pesquisa e Extensão. 1 month ago the routes Projetos de Extensão e Grupos de Pesquisa, ...
0
votes
1answer
132 views

Custom Rewrite Rule for Custom Post Type with URL Param

I am trying to create a custom rewrite rule for a custom post type where This: http://test.loc/products/directory/?c=some-value Should become this: http://test.loc/products/directory/some-value ...
1
vote
0answers
148 views

How do I change the custom taxonomy slug to be the same as the custom post type slug?

I am creating a WordPress site with a Products page, and I'm using a Custom Post Type to create the products to display under this page. Here is a sample of the product structure I have created: ...
1
vote
1answer
336 views

Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache

How to rewrite url of wordpress rest api from http://example.com/?rest_route=/wp/v2/ to http://example.com/wp-json/wp/v2/ without changing (default) permalink structure? Need this for apache (htaccess)...
0
votes
0answers
20 views

.htaccess woocommerce config with static html homepage

I've got a woocommerce shop which has a static index.html as a homepage. If a customer visits the checkout the ajax requests gets the response from the the index.html page because the request is ?wc-...
0
votes
0answers
18 views

Need help to set up a custom rewrite rule for a custom post type

I need help to set up a custom rewrite rule for a custom post type. The actual website URL structure can be any of the following links: https://website.com/android/post-name/?query=string1 https://...
1
vote
1answer
22 views

Wordpress custom post type permalink: website.com/post-name/post-id

I am trying to build a custom permalink in wordpress for my custom post type artikelen (exact slug). I found code online and it seems to do the work with transforming the links with a custom structure ...