Title: Fix for using different ports
Last modified: August 20, 2016

---

# Fix for using different ports

 *  [caleb.land](https://wordpress.org/support/users/calebland/)
 * (@calebland)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/fix-for-using-different-ports/)
 * I like your plugin, but I ran into a problem when I use it on a site that runs
   on a port other than 80.
 * I configured the plugin to redirect anonymous users to the login page, but when
   the user logged in, it would yield a 404.
 * The problem was that the login form was redirecting me to the page I requested,
   but stripping the port.
 * The solution is to tack the port onto the return URL.
 * I don’t know the best way to get the code to you, but here it is:
 * Replace Line 528 of CTXPS_Security.php with:
 * if (empty($_SERVER['HTTPS'])) {
    wp_safe_redirect(wp_login_url('http://'.$_SERVER['
   SERVER_NAME'].($_SERVER['SERVER_PORT']!=='80'?':'.$_SERVER['SERVER_PORT']:'').
   $_SERVER['REQUEST_URI'])); } else { wp_safe_redirect(wp_login_url('https://'.
   $_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']!=='443'?':'.$_SERVER['SERVER_PORT']:'').
   $_SERVER['REQUEST_URI'])); }
 * I know it’s not the prettiest, but it gets the job done.
 * Thanks for the plugin, it saved me a lot of work.
 * [http://wordpress.org/extend/plugins/contexture-page-security/](http://wordpress.org/extend/plugins/contexture-page-security/)

The topic ‘Fix for using different ports’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contexture-page-security_324aa9.svg)
 * [Page Security & Membership](https://wordpress.org/plugins/contexture-page-security/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contexture-page-security/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contexture-page-security/)
 * [Active Topics](https://wordpress.org/support/plugin/contexture-page-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contexture-page-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contexture-page-security/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [caleb.land](https://wordpress.org/support/users/calebland/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/fix-for-using-different-ports/)
 * Status: not resolved