You can’t “redirect” to the external site in .htaccess – there is no way for your script to do the “MITM” bit to check their credentials.
Instead, you would need to internally rewrite the request to your PHP script (in .htaccess). Your PHP script then checks that the user is logged in, etc. as you are doing and then your PHP script issues the appropriate redirect – in the same way your script is currently redirecting back to your own site when authentication fails (although arguably that should be a 403 instead).
For example, before the WordPress front-controller:
RewriteEngine On
RewriteRule ^resources$ /php-authentication-script.php [L]
The above will internally rewrite any request for /resources to your /php-authentication-script.php. The URL in the browsers address bar remains as /resources, until your PHP script issues the redirect.
Related Posts:
- WordPress Ajax always returns a 404 error
- Calling a method from functions.php on a click of a button
- Nice scroll to wordpress
- Javascript code inside “” in core WordPress files .php
- Minify HTML, CSS, JS with PHPWee?
- Slide in Panel WordPress Post
- Show post in slider
- Populate dropdown with Child Pages based on Parent Page chosen
- search and replace preword from author
- parts of url disappear when using # inside href=”” [closed]
- Redirect to another page using contact form 7? [closed]
- Noscript not working as it should in wordpress site
- Add Codepen animation as Preloader to WordPress
- HTML escaping data with ajax requests
- Override user-edit.php to design own profile page
- How to allow download url redirection only if user logged in WordPress site?
- How do i add slugs to a URL, but still redirecting to the same page
- Calling PHP Titles inside Javascript Markup
- Link to page with posts of specific type
- Replacing WordPress Icons (menu,icons32, etc)?
- Is it possible to isolate and use WordPress functions outside of wordpress
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- html form: redirect page after form completes submit function and posts data
- WordPress User Meta value variable into Google Gauge Chart
- Unable to display multiple parameters from url by javascript through shortcodes
- Search bar for wp menu
- Adding HTML Code to Replace Text in PHP
- Executing php on button press
- Add other class content with reference class value
- Using Google Analytics in an enqueued JS file
- Add Link to PHP message
- separate list of programs in html/javascript coming from php
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- How do I disable cache for a certain page?
- Current WordPress Page Title as Search Parameter into A Tag
- Rewrite rule not working, but only when parameter is text
- WordPress Slider is not working
- Show subcategory name selected in specific category woocoommerce
- sessionStorage saves input value in browser but it is not loaded in the form field
- Collapsible menu on post sidebar only expands and does not collapse
- Target a specific container to style on WordPress storefront theme
- I want url from a file in media using title file
- scroll scrpit to particular button position to next id when click button
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Where to find the html for WordPress site? [closed]
- I need help implement a Javascript code into the PHP file
- Trying to customize wordpress drop down categories
- Is there a better way to output HTML as a shortcode?
- Load wp_editor on button click
- bloginfo url in javascript
- Slick slider not working on wordpress
- How do I change/modify the_post_thumbnail(); html output?
- How to call a PHP function from Javascript in WordPress
- Correct way to make static pages editable in wordpress
- Header has extra HTML block at top before my code
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How is WordPress manipulating the posts like there are folders?
- How can the plugin directory path be returned into ?
- How can I use a modal window to display the current post in loops featured image?
- Add a class to the anchor tag on HTML5 gallery
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Use DOMDocument with ob_start breaks my HTML code
- Passing UTM Parameters To Modify Page In WordPress
- Settings API callback function inserts html quotes from nowhere
- How create a Shortcode with hover and complex options
- Add / Update Custom Fields After Select Pictures in Media Window
- Accessing WPDB Multidimensional JSON Array w/ Javascript
- Search WordPress using static html page
- How to check if the current page is at a specified path in the URL?
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Highlight the links without using dropdown
- Incrementing PHP variable onclick to display posts by month
- Remove in post content
- JS file is not loading when i put wp_head() and wp_footer
- Is it possible to restrict files from your wordpress uploads (not logged-in users or guest)?
- Adding attribute to the post.php form tag in wp-admin
- How to add PHP pagination to wordpress
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress permalink issue
- Additional file upload in Gutenberg page options/featured image
- Variation prices breakdown only for single product page
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- Google CSE Malfunctions via Chrome/Safari on Mobile When Clicking on Either Search Icon/Menu Icon. How to Make Google CSE Default Theme Search
- Move Jquery.js to Footer
- Splitting table data to pages with numbers
- add bootstrap modal after login in wordpress
- nested divs, classes for a grid in loop [duplicate]
- featured post as div background
- Php echo into tag
- Add specific phrase after every product title including the discounted price? [closed]
- link to page_for_posts
- WP_Query not returning results
- How do I link the side images?
- How to create different templates for woocommerce single-product.php?
- How can i add a script with parameters?