Thank you guys for the help and the tips.
@Dexter0015 Tip helped me in the end to get it done.
This is how my 404.php looks like now im only checking if in the url the string is present and show the template for it.
Thanks everyone again
edit:
i changed the search values to /services/ and /blog/ so it was a bit better when the url has services inside or something it got messed up now it works perfectly for me
$postUrl="http" . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
get_header();
if (strpos($postUrl,'/services/') !== false) {
get_template_part("error-pages/services-error-page");
} elseif(strpos($postUrl,'/blog/') !== false) {
get_template_part("error-pages/blog-post-error");
}else{
get_template_part("error-pages/general-404-error");
}
get_footer();
Related Posts:
- PHP – redirect https to http and www to non-www
- 3 blogs same installation, without WP MU
- How to allow download url redirection only if user logged in WordPress site?
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- wp-login – unable to redirect user to a custom login url
- How do I make a redirect in PHP?
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- How to create custom 401, 403 and 500 error pages?
- Redirect to Page after Post Submit
- Bypass .htaccess when using download_url
- How to redirect users to custom lostpassword page?
- How can I run a .php file located in my site’s root folder?
- Fix 403 error on WordPress multisite network using subdomains
- How to redirect all 404 in a WordPress subdirectory to the index.php of subdirectory?
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- How to override .htaccess with new rules without ftp or edit it manual
- Logout and redirect using the WP Menu
- Change links automatically to affiliate links
- PHP If user is logged in & on home page redirect
- 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’
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- WordPress does not load page.php, return 404.php
- How to change home or site url using action hooks or filter?
- Apache Fallback instead of add_rewrite_rule
- Two Different Links for Same Product – WooCommerce [closed]
- Was told to change the .htacess file form .html to .php so this would work properly
- WordPress homepage infinite redirect
- Redirect undesirable domain
- how to combine wordpress htaccess on my root domain + php on subfolder
- subdirectory index.php is not working
- custom url rewrite for wordpress
- Loading index.php contents which located outside blog folder for post single page
- WordPress add_rewrite_rules for custom URLs ending in .html
- Set Cache-Control header for 301 redirects
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- Showing latest post without 301 redirect
- Having Issue on Redirecting With Session in WordPress
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- Troll the hackers by redirecting them
- WordPress redirect redirecting too many times or not at all
- Using Argument from Function to Re-Direct Visitor (WordPress)
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Seo Friendly Filter URLs
- PHP Redirect condition
- Removing files programmatically
- Manually Create PHP Page For A Redirect
- Writing a link cloaking plugin
- WP insert post Redirect after function has executed
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Download file and redirect to page or vice versa
- How to make Subdomain work for product_tag?
- Add more user roles to a PHP logout redirect function [closed]
- How to serve WordPress folder over subdomain?
- 404 on old link after changing post url
- WordPress url By country code?
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- Pages from admin dasboard missing after site migration
- Remove all feeds and return custom 404 page
- Rewrite rule not working, but only when parameter is text
- Internal Server Errors – Moving working multi-site install to my localhost
- Infinite loop when logging out using custom login form
- Redirect User when they click Menu Option
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- wp-login.php?redirect_to=https problem
- How come there is no error if I upgrade WordPress core after locking .htaccess permissions to 644?
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- .htaccess file doesn’t work, with hundred tries
- How to change query string with pretty URL in WordPress using .htaccess file
- Override 404 when navigating to single php file
- Problem with ajax request and directory structure after site migration
- Submit to itself don’t work
- How can I add “.html” to the end of a single URL on a WordPress website?
- Resource 404 error on multisite subdirectory install
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- Submitting my form to the database and then redirecting to payment site
- Redirect homepage /page/1/ to /blog/page/1/
- Enabling XSendFile causes 404 for images on WordPress Multisite / Network
- Why I can download any file except PHP files from a URL but I can download any from another site?
- Get permalink for a post from inside WordPress and route to a related site
- Link to external page has wordpress blog-url inside
- How to create a WordPress PAGE in another folder?
- index.php file keeps redirecting to a non-existent index.html file?
- Redirect loop upon installation of my plugin
- Increase Upload Size with htaccess | MAMP
- wp_login_url always redirects me to wp-admin
- Redirect WordPress page to the latest created post by the logged in author/user
- Can I redirect media urls (not attachment pages) to the post parent?
- Processing data and redirecting with query string