First, add a WordPress page named game
to direct requests to.
Next, add the game
query var so WordPress knows what it is:
add_filter( 'query_vars', 'wpa_query_vars' );
function wpa_query_vars( $query_vars ){
$query_vars[] = 'game';
return $query_vars;
}
Then, add a rewrite rule to handle the incoming requests and direct them to your page:
add_action( 'init', 'wpa_add_game_rule' );
function wpa_add_game_rule() {
add_rewrite_rule(
'game/([^/]+)/?',
'index.php?pagename=game&game=$matches[1]',
'top'
);
}
Last, create a template named page-game.php
and add get_query_var( 'game' )
to see the requested game.
Related Posts:
- Bypass .htaccess when using download_url
- Loading index.php contents which located outside blog folder for post single page
- Redirect homepage /page/1/ to /blog/page/1/
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- How to create custom 401, 403 and 500 error pages?
- PHP – redirect https to http and www to non-www
- How can I run a .php file located in my site’s root folder?
- Fix 403 error on WordPress multisite network using subdomains
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How to redirect all 404 in a WordPress subdirectory to the index.php of subdirectory?
- WordPress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]
- How to run multiple websites from single WordPress setup
- Using PHP in a Stylesheet (possibly a “.htaccess” problem?)
- How to override .htaccess with new rules without ftp or edit it manual
- WordPress-site can be reached on x.x.x.x/index.php – but not directly on the IP without index.php
- Change the actual (or viewable) WordPress directory structure
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Cannot get media type from ‘x-mapp-php5’
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- How to change home or site url using action hooks or filter?
- Apache Fallback instead of add_rewrite_rule
- 3 blogs same installation, without WP MU
- Two Different Links for Same Product – WooCommerce [closed]
- Was told to change the .htacess file form .html to .php so this would work properly
- How to change redirection route to a php page for making it only accessible by logged-in members?
- how to combine wordpress htaccess on my root domain + php on subfolder
- subdirectory index.php is not working
- custom url rewrite for wordpress
- WP & Server Speed [Teacher Question]
- How can I hide that I Use WordPress (with W3 Total Cache)
- WordPress add_rewrite_rules for custom URLs ending in .html
- Troll the hackers by redirecting them
- Seo Friendly Filter URLs
- How to allow download url redirection only if user logged in WordPress site?
- How to disable all logins except Network login in WordPress Multi site?
- Removing files programmatically
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- Why is home page content not displaying with this rewrite rule?
- Modifying WP URL handing code?
- Disable category RSS Feeds on WordPress blog with PHP
- Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts
- How to make Subdomain work for product_tag?
- How to serve WordPress folder over subdomain?
- Pages from admin dasboard missing after site migration
- Rewrite rule not working, but only when parameter is text
- Internal Server Errors – Moving working multi-site install to my localhost
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?
- How to block access to a folder inside of wp-content for non logged in users?
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- How to change query string with pretty URL in WordPress using .htaccess file
- Upload images from one server to an other in wordpress
- Problem with ajax request and directory structure after site migration
- How can I add “.html” to the end of a single URL on a WordPress website?
- Resource 404 error on multisite subdirectory install
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- Enabling XSendFile causes 404 for images on WordPress Multisite / Network
- how to exclude admin page from add_rewrite_rule in wordpress
- WordPress rewrite question
- Why I can download any file except PHP files from a URL but I can download any from another site?
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- How to use multiple 404 Error Pages in WordPress
- Increase Upload Size with htaccess | MAMP
- Is it possible to generate a page without create in the admin?
- Admin Media grid view images won’t load
- WordPress remove EXIF Data from specific Thumb
- When must I use and verify nonce?
- Displaying a button on each post
- How can I set a default category for a custom post type in wordpress?
- Slider loading issue
- Sort posts by custom fields value using dropdown menu
- Cause of Blank Lines Being Added to WP FIles?
- Weird 404 URL Problem – domain name being placed at end of urls
- Trouble checking if custom woocommerce checkout field is empty or not
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Where can I find the inline-css of my theme header?
- Remove empty terms from array, sort alphabetically, update back to repeating field
- custom plugin with upload files does not work
- Authentication from sub-folder non-wp cookie WordPress
- In adding CMS functionality to static website, is complete conversion the only way?
- Rewriting subfolders to specific parent folder in WordPress
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- Error establishing a database connection (configuration)
- Converting Array to String Issue [closed]
- ElseIf Statement with ACF Group field
- WordPress randomly redirects with 301 after logging in
- How to change href of a Widget menu item link?
- Can’t get_users info by using json_encode
- Newbie question. Login/Registration. New PHP page
- Using Custom Javascript and pHp to send email to myself when a user clicks on an input button but only works on Chrome, IE, and Micorosft Edge
- Page returning ID from array, how to return the correct values for post in acf wordpress
- WordPress site cant display media when it’s live
- Highlight main menu when on specific posts or pages
- wc_add_notice not working on cart page
- How to convert my comment.html to comment.php
- It’s not showing full content for posts pages in wordpress “[…]” while customing some changes in the style.css file [closed]
- How do I convert a custom field to a php date format? [closed]