Using .htaccess to redirect /da/ to / in URL
Using .htaccess to redirect /da/ to / in URL
Using .htaccess to redirect /da/ to / in URL
Rewrite rule giving 404 error
Rewrite URLs in a Custom Post Type with Multiple Taxonomies
Rewrite rule to simulate page hierarchy results in 404
Turns out i was able to make it work by hooking into parse_request . add_action(‘parse_request’, ‘serve_index_json’, 0); function serve_index_json($wp) { // Exit early if not the right request if (‘my-category-slug/index.json’ !== $wp->request) { return; } $data = array(); $args = [ ‘posts_per_page’ => -1, ‘category_name’ => ‘my-category-slug’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => … Read more
The technical answer to this is to put an .htaccess file inside your wp-admin folder with this code: # Remove .php from pages so you can use /wp-admin/edit RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php # Use /wp-admin/addnewpost RewriteRule addnewpost post-new.php The practical answer is that this is completely horrible, involves … Read more
You HAVE TO add a rewrite rule to WordPress. That can be done withou touching .htaccess. For example: add_action(‘init’, ‘cyb_rewrite_rule’); function cyb_rewrite_rule() { add_rewrite_rule( ‘toto/([^/]+)/?$’, ‘index.php?pagename=$matches[1]’, ‘top’ ); } If you need access to the second part of the URL as query var, you can do this: add_action(‘init’, ‘cyb_rewrite_rule’); function cyb_rewrite_rule() { add_rewrite_rule( ‘toto/([^/]+)/?$’, ‘index.php?pagename=$matches[1]&secondpart=$matches[2]’, … Read more
Maybe it´s easier to output some content from a different page/post in your search template which got a fixed slug. I for example use this: $page = get_posts(array(‘name’ => ‘welcome’)); if ($page) { echo ‘<h1>’.$page[0]->post_title.'</h1>’; echo ‘<p>’.$page[0]->post_content.'</p>’; } This fetches the post with the slug “welcome” and displays its content. As I don´t use a … Read more
If city belongs to the page post type, then your rule should either be: add_rewrite_rule( ‘^city/([^/]*)/?’, ‘index.php?pagename=city&id=$matches[1]’, ‘top’ ); or: add_rewrite_rule( ‘^city/([^/]*)/?’, ‘index.php?page_id=5&id=$matches[1]’, ‘top’ ); Using p, the query will assume post type is post, not page. Also, if your code uses $_GET[‘id’] to fetch the value, this will no longer work with a rewrite … Read more
It’s not understandable for me, but the second definition works now. No idea, why it didn’t work before, but I guess, somewhere I made a small mistake. Sorry, for my useless post 😉