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
- Is It Possible to Block Redirect Checker Tools from Knowing Where URLs are Redirected?
- Create custom blocks for bootstrap
- HTML table from shortcode with multiple parameters
- Run a Parallel PHP Application with WordPress
- Click loads template via ajax
- Archive dropdown styling not applied
- Wrong links in WordPress?
- Newbie question: no index.php? in my plain wordpress permalink
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- How to display a value from a radio button in the options menu in wordpress
- Display notification only once
- Header has extra HTML block at top before my code
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- How is WordPress manipulating the posts like there are folders?
- javaScript in section of WP API
- To echo or not to echo?
- Blank space at beginning of tag?
- How do I add HTML to a PHP function [closed]
- admin-ajax.php responding with 0
- Using wp_localize_script to store the template url into a variable to use in JS
- Custom image upload
- How to display recent posts on home page with custom HTML
- How can the plugin directory path be returned into ?
- WordPress automatically adds tags when pasting code, how to stop it?
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- How can I add tinymce editor in WordPress with jQuery?
- How to speed up admin-ajax.php in wordpress
- JQuery not working on WordPress Admin page [closed]
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- Placing raw HTML inside a WordPress shortcode
- How to only show page id as body class?
- Change the actual (or viewable) WordPress directory structure
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Sending jsPDF documents to the server
- Shortcode content output but not in correct place