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

get_categories() retrive post_tag instead category

I want to rewrite my category to a specific URL. but I get post_tag instead of category when I use get_categories(). Here my code add_filter( 'category_rewrite_rules', '...
0
votes
0answers
19 views

.htaccess to redirect to a wp page

My custom .htaccess commands are above the WP ones. This is working: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^$ wp-content/ahoj.txt [N] </IfModule> It shows the contents of ...
0
votes
0answers
20 views

When I modify the product's permalink, the pages stop working

I'm trying to modify the Woocommerce slugs with the object $wp_rewrite. When I modify it, everything works as I put it, but the rest as the pages stop working. Here the code: public function rewrite():...
0
votes
1answer
8 views

How to change Custom Permalink for Taxonomy? (remove the slashes from term-slug)

I have my code to register my custom taxonomies. function themename_custom_taxonomies() { // Coaching Method $coach_method = array( 'name' => _x( 'Nieruchomość', 'taxonomy general ...
0
votes
0answers
10 views

Best Place to 404 a Non-Matching Custom Query Var

I've created a 'tabbed' layout on custom taxonomy archives on my website and successfully rewritten my permalinks so that visitors to mywebsite.com/player/player_name/tab_name see some conditional ...
1
vote
1answer
29 views

remove query arg from url after set query

i make migration plugin from specific script to wordpress, but i have a problem on redirect old urls to new one old urls is like book.php?view=12a34b56 and i want redirect it to book/12a34b56 i try to ...
0
votes
1answer
11 views

Rewrite only if no other matching page is found

I'm rebuilding a site in which I am required to change the URL structure for archive pages to something that WordPress doesn't handle by default. I have a custom post type named product, which has a ...
0
votes
0answers
17 views

ErrorDocument 410 gives me back a 302 header

I've deleted several pages and tags from my site, and bases on my SEO recommendations I've redirected them to 410. I've done that in my .htaccess file this way: RewriteRule ^tag/lorem/?$ - [G] ...
0
votes
0answers
20 views

How can I make rewrite rules for a custom post type?

I'm trying to create rewrite rule which will work this way: when user enters URL site.com/projects/projectname/cityname it should work as site.com/?projects=projectname&city=cityname, where: ...
0
votes
1answer
15 views

Getting back a permalink from custom url

okay i have made my own rewrite rule, with the add_rewrite_rule function in wordpress to get a custom url, for an plugin page. add_action( 'init', function() { add_rewrite_rule( 'login/?$', 'index....
0
votes
1answer
49 views

URL rewrite for mu-plugin assets

I have a semi-bespoke scenario, but one that works best for out environment sharing the code workload and accessibility (and version control). We have a multisite that all abide by the same core ...
0
votes
0answers
10 views

Why did my registered rewrite rules get deleted?

I'm using this code to register a rewrite rule: class Affiliate_Link_Utils_Redirector { public static function install() { add_filter('rewrite_rules_array', array(__CLASS__, '...
0
votes
1answer
15 views

Rewrite/Change custom taxonomy slug

I want this url: => mydomain.com/genre/chant to be rewritten as => mydomain.com/chambers/chant. I want the users to access mydomain.com/chambers/chant instead of mydomain.com/genre/chant. genre ...
1
vote
1answer
18 views

NGINX rewrite rules for sub subdomains

I was wondering if it's possible to set-up an NGINX rewrite rule for a WordPress Multisite that redirects anyone using the following: www.sub.domain.com to sub.domain.com. The issue we seem to be ...
1
vote
1answer
36 views

Can't get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together

Problem specification I'm implementing a website that is meant to host podcast shownotes and transcripts, and so I want custom permalinks and shortlinks for the webpages: Permalinks of the form /...
4
votes
2answers
59 views

How to change default page slug?

I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url: http://example.com/job-slug/apply Where, job-slug can be any job. i.e Programmer, Developer etc.. ...
0
votes
0answers
34 views

Custom taxonomy shared across two custom post types - url rewrites

I'm using CPT-UI to create my custom post types and taxonomies. I have two post types - aulocations and uklocations these work and show up as: /au/locations/{location-names} /uk/locations/{location-...
0
votes
1answer
17 views

Name page template properly

I have custom taxonomy in place which builds URL that way: domain/course/course-name/lesson Course - is a custom post type. I am facing difficulty to reach the right template for lessons. I've tried &...
0
votes
1answer
116 views

How to add_rewrite_rule with two parameters to a single view page?

I'm having troubles understanding how add_rewrite_rule works in my case. I have a page which lists news from an external source. All items are linked with a "read more". Those links look ...
0
votes
0answers
9 views

Exclude image from cloudflare hotlink protection

I am want to exclude my newsletter images from Cloudflare's hotlink protection Based on Cloudflare's documentation, it is possible to do this with serving the image from a "hotlink-ok" ...
1
vote
0answers
60 views

Help with Rewrite Rule for Custom Post Type with Query String

I'm trying to get a custom rewrite working: I've got the following URL pattern for a custom post type of 'product': /au/product/product-name-one/?type=customtype1 /au/product/product-name-one/?type=...
0
votes
0answers
83 views

How do I get the correct URL?

Helo, WordPress Community! Help me, please. Created a custom post type with one taxonomy added as a category. Overwrite rules have also been created to display the complete structure of the CNC, for ...
1
vote
0answers
22 views

Rewrite URLs - Custom Post Type - Post Slug, Taxonamy Slug

Am using a third-party plugin for listing schools. Custom Post Type = school Custom Post Taxonomy 1 = school_type (eg. values = Primary, Intermediate) Custom Post Taxonomy 2 = school_location (eg. ...
2
votes
0answers
33 views

How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?

In WP 5.4.x, I was able to add a number to the URL for any page, post, etc. (incl. custom post types), which WP interpreted as the 'page' for a multi-page post, even if that page or post didn't ...
1
vote
2answers
50 views

URL Rewriting for PHP script on an image URL

I built an image randomizer so that when I open a .php file in a URL that it displays the image with readfile($randomImage);. This works locally but when I upload it to the server it gets blocked by ...
0
votes
0answers
20 views

How Can I Create a Friendly Slug for a Dynamic Page?

I built a dynamic page template that pulls biography information from a MySQL table. The page works fine but the URL is ugly. Officer-Biography/?ID=1 I have a set of canonical slugs that I want to use ...
1
vote
2answers
31 views

Create Dynamic SEO Friendly URL for Virtual Page

I have a Wordpress site that is built to be a job listing board, and I'm looking to create SEO friendly URLs based on data that is stored in the database. The URL structure should include the state ...
1
vote
2answers
27 views

add_rewrite_rule with query variables

We have rewrite rules as: add_action( 'init', function() { add_rewrite_rule( 'app-api/v2/ecommerce/([a-z0-9-]+)[/]?$', 'index.php?p=$matches[1]&post_type=product' ); } ); for the URL - www....
0
votes
0answers
23 views

WordPress rewrite rule depend on meta values not ids

I have a custom post type and i'm using the rewrite rule to change the URL from mysite.com/collection?brand1=365&brand2=412 to mysite.com/collection/compare/365-412 But I want to depend on meta ...
0
votes
3answers
79 views

Why wordpress rewrite my custom URL?

I am new in wordpress There may a mapping question in my website I hope this SEO URL is work and get Post data: http://domain/web/d-post/M00069/TomLi If not using SEO URL(get action), it is work! http:...
0
votes
0answers
16 views

Redirect default pagination page to template page's pagination

How do I redirect the default pagination pages such as http://mywebsite.com/page/2 to a template page so it looks like http://mywebsite.com/articles/page/2 articles is a custom template page and not a ...
0
votes
0answers
11 views

Multiple Taxonomies rewrite rules for wordpress

i would generate a permalink for multiple taxonomies for a custom post type. I have a custom post type: Location I have these taxonomies: City Location Type I would generate a pretty url while while ...
0
votes
1answer
18 views

SEO Concerns With Rewrite Rules

I have a few rewrite rules that allow me to have specific URLs for search paremeters. For reference, they are: add_filter('rewrite_rules_array', 'mmp_rewrite_rules'); function mmp_rewrite_rules($rules)...
0
votes
1answer
16 views

Category permalinks don't work even after flushing

I have created a custom post type (portfolio) and I'm using the built-in Category taxonomy with it. When I view the category archives page, only regular posts are showing under the category, my custom ...
1
vote
1answer
73 views

Wordpress rewrite rules don't need ^?

For example this code class My_Sitemap { public static function install() { add_filter('rewrite_rules_array', array(__CLASS__, 'rewriteRules'), 1, 1); global $wp_rewrite; ...
0
votes
1answer
50 views

Custom permalink structure for custom post types including multiple taxonomy

The goal is to have a structure like this: example.com/tax_1/tax_2/post_name This code produces the right structure but the post can't be found (404) // Register custom post types function ...
0
votes
1answer
44 views

Set parent for custom post type archive rewrite url

I have 2 custom post types Offices register_post_type('offices', [ 'labels' => [ 'name' => __( 'Offices' ), 'singular_name' => __( '...
0
votes
0answers
21 views

Creating two pages out of a custom post type

I am trying to create two different URLs from a single post type with custom post types. Currently I have something like from my post type: url.com/big-jellybeans/blue big-jellybeans being the archive,...
0
votes
0answers
32 views

WordPress - replicate same globals, query vars and query for an alternate endpoint

We are building a hybrid mobile app for a website. The app will display a minimal version of the webpage, for example if the website displays post title, post content, sidebar, widgets, etc, then the ...
0
votes
1answer
31 views

Rewrite rule regex help required

Hoping you can help with this... WE have a 'serivces' custom post type that allows a 'service' to have a parent 'service'. Our custom rewrite rule works for top-level services but not child services. ...
0
votes
0answers
57 views

Wordpress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin

The below code is not working. I wanted to use add_rewrite_rule wordpress function for multiple post types but it works if i use it once. I want some one who can make this code work. function ...
0
votes
0answers
24 views

add_rewrite_rule not working for blog category page

add_rewrite_rule('^blog/games/(a-z|z-a|most-recent|most-viewed)(/page/([0-9]{1,}))?\.html$', 'index.php?blog_category=game-guides&index_sort=$matches[1]&paged=$matches[3]', 'top'); after ...
0
votes
0answers
18 views

pretty urls for categories instead of query string along with pretty pagination

I am trying to add a pretty urls instead of query string like customers/reviews/xyz here reviews is a custom post type and xyz is category customers/reviews gives all reviews and customers/reviews/...
0
votes
0answers
12 views

How to get the real URL, after the rewrite rules were applied in a subfolder multisite

Disclaimer: My PHP and WordPress knowledge is limited. Context: Ok, I've tried to wrap my head around this issue the whole day without avail. The problem is the following. I try to make a demo ...
0
votes
0answers
17 views

Redirect empty search to another page

I am using the following code to change the url of my search results page: function wpb_change_search_url() { if (is_search() && !empty($_GET['s'])) { wp_redirect(home_url("/suche/...
0
votes
0answers
18 views

Assign Woocommerce Product Category to Existing Taxonomy

I created a custom taxonomy named a custom post type Product and a taxonomy Product Category (product-category) prior using the WooCommerce plugin: register_taxonomy( "product-category", ...
0
votes
1answer
14 views

Dynamic URL with rewrite rule not working

I'm trying to update my link from this: https://dev.brunchwork.com/next-event/?eb_event_id=106098978902 To this: https://dev.brunchwork.com/next-event/[guest_name_here]/[event_id_here] Following this ...
0
votes
0answers
16 views

How to solve page not found problem with pagination in WordPress?

I am new on WordPress and I add the rewrite rule for search in Twenty-Twenty theme, but now the problem is when I go to second page using pagination, it returns 404 error. Here is the rewrite rule ...
0
votes
0answers
11 views

rewrite the url keeping the previous one

I would like to understand if it is possible, through add_rewrite_rule, to do this: a user types: https://example.com/username the user sees the page: https://example.com/author/username the url ...
0
votes
0answers
7 views

How to make mydomain.com/[post_typeA]/[post_nameB]/[post_nameA] not 404: custom post types rewrite rules. ([PostTypeA]/[ParentPage]/[ChildPage])

I scoured this forum and a lot of others but I have not found the answer and starting to doubt whether it's even possible.. I'm trying to make a site with week and day posts, a day post is called "...

1
2 3 4 5
22