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
- How do I make a redirect in PHP?
- 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
- Redirect to Page after Post Submit
- Bypass .htaccess when using download_url
- How to redirect users to custom lostpassword page?
- Fix 403 error on WordPress multisite network using subdomains
- How to redirect all 404 in a WordPress subdirectory to the index.php of subdirectory?
- Insert code when users come from an specific referer
- 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
- WordPress template_include filter not working properly
- Logout and redirect using the WP Menu
- Change links automatically to affiliate links
- 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
- How to change redirection route to a php page for making it only accessible by logged-in members?
- Redirect undesirable domain
- how to combine wordpress htaccess on my root domain + php on subfolder
- custom url rewrite for wordpress
- How do I display the main domain for my WordPress install?
- Loading index.php contents which located outside blog folder for post single page
- Problem with login form
- WP & Server Speed [Teacher Question]
- WordPress add_rewrite_rules for custom URLs ending in .html
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- 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
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Where to insert redirect code based on http_referer?
- Seo Friendly Filter URLs
- Is this a correct usage of ob_start() in my WordPress project?
- How to disable all logins except Network login in WordPress Multi site?
- PHP Redirect condition
- Removing files programmatically
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- Simple seo-friendly custom $_GET url rewrite with htaccess
- Redirect to current user page upon link click
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress permalink issue
- WP insert post Redirect after function has executed
- How to redirect non logged in mobile users to page on same site?
- 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
- 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
- WordPress on Ubuntu – “File not Found” for home.php – Trying to Redirect to Root Folder
- 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
- Redirect User when they click Menu Option
- WordPress: Redirect Main Site to Subsite in Multisite Where user is NOT logged in
- 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?
- How to block access to a folder inside of wp-content for non logged in users?
- 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
- Upload images from one server to an other in wordpress
- 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?
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- Submitting my form to the database and then redirecting to payment site
- 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
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- 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