Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to write RewriteRule for login in multisite

Well, I built a multisite, mysite.com composed of mysite.com/subsite1, mysite.com/subsite2… and use Theme my Login plugin.
As I wanted all the login requests to be sent to mysite.com/login, I found a rewrite rule to acheive that:

RewriteRule ^(.*)/login/$ http://mysite.com/login/ [L,QSA,NE]

Basically, after my readings and anderstanding, this ^(.*)/ will find any url with ‘login’ in mysite.com and subsites, and redirect it to mysite.com/login.
Explaining the flags from: http://httpd.apache.org/docs/current/rewrite/flags.html:

“The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed.”
“With the [QSA] flag, a request for /pages/123?one=two will be mapped to /page.php?page=123&one=two. Without the [QSA] flag, that same request will be mapped to /page.php?page=123 – that is, the existing query string will be discarded.”
“Using the [NE] flag prevents (special characters, such as & and ?, for example, from being converted to their hexcode equivalent.
RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]. This example will redirect /anchor/xyz to /bigpage.html#xyz. Omitting the [NE] will result in the # being converted to its hexcode equivalent, %23, which will then result in a 404 Not Found error condition.”

The combination of those rules will send a user to mysite.com/login, then redirect them to the previous page after login.

I hope my explanation is helpful -;)

Related Posts:

  1. Multisite – Redirect All Users to Subsite Home Page on Subsite Login
  2. Auto Redirect after login
  3. Multisite: Redirect Subsite Administrator to Subsite Home Page, Bypassing Dashboard
  4. Admin user getting redirected to /wp-admin/user
  5. Redirect Main Site to Subsite in Multisite WordPress
  6. Is there a is_user_logged_in() for multisite?
  7. Why is WordPress Multisite redirecting to wp-signup.php and how to fix it?
  8. How to disable Multisite sign-up page?
  9. Unable to login to new custom domain on multisite?
  10. WordPress multisite,several different languages,page redirect?
  11. WordPress Multisite – Multiple subfolders for blogs
  12. WordPress multisite subdirectory redirect infinite loop issue
  13. Multisite 404 errors and non-www redirecting to home page
  14. share login/logout sessions across two installs?
  15. How to Login Once to an Entire WP Multisite Network
  16. multisite htaccess 301 redirects
  17. W3 Total Cache Plugin with WP 3 MultiUser [closed]
  18. Redirect all users, except network administrators, from the main site to a subsite
  19. Multisite wp-admin redirect loop
  20. Multisite non-www domain redirects to sign-up
  21. WordPress network (multisite) /wp-admin/ redirect loop (ERR_TOO_MANY_REDIRECTS)
  22. Domain redirect in WordPress multisite
  23. Multisite non www domain gives registration error but should redirect to www.domain.com
  24. 301 Redirects for posts, category, pages from original domain to sub-domain of multisite
  25. Trying to access second site dashboard on a multisite configuration proceeds to an error
  26. Redirect loop (only for multisite network admin)
  27. WordPress Multisite Login Access
  28. Why wordpress multisite redirect to wp-signup if site exists?
  29. Sub-subdomain getting redirected to main domain
  30. Multisite network admin – URL / redirect error
  31. Subdomain login problems
  32. WordPress Multisite local: wp-login.php refreshes on login Chrome Browser
  33. ‘Remote Login’ with MultiSite Domain Mapping still forcing users to login to all blogs individually?
  34. How to exclude a directory from WordPress permalinks in a Multisite environment?
  35. Redirect subdomain homepage to domain specific page in wordpress multisite
  36. WordPress multisite subdirectory on nginx behind reverse proxy
  37. How to stay logged in on a multisite with different domains?
  38. Multisite Redirect issue
  39. How to Redirect login User with Mapped Domiain Primary blog Url to Original Sub-site Url
  40. Disable domain redirect
  41. Redirect users on logout
  42. Multisite, multiple domains per site
  43. Multisite Network menu links not updating
  44. Login on Multiple Sub-Domains without Multisite
  45. How to disable the default WordPress redirect to non-www URLs?
  46. Fresh Multisite Install – Can’t Log In
  47. https redirect hell (adding www)
  48. WPMU Development Environment
  49. Redirect subdomain in Multisite installation?
  50. Issue with htaccess redirection in WP Multisite
  51. Site kit Google Analytics setup giving Error: {“error”:”invalid ‘redirect_uri'”}
  52. All pages have 302 redirect, which I can’t remove
  53. Why my deleted url is redirecting to random post?
  54. Redirect only posts to New Domain
  55. WordPress MultiSite login to the respective site
  56. Multsite redirecting to the main site
  57. Multisite setup help – plain domain/subsite always redirects to domain with subdir multisite
  58. Redirect & permalink problems after moving multisite to a new server
  59. Temp URL Redirect Loop
  60. Installed domain-based Multisite but can’t access wp-admin (redirect loop)
  61. Redirect Site Geologically
  62. How to configure Multisite Network with randomized hostnames?
  63. WordPress Multisite Strange Redirect on Primary Site
  64. Wrong Redirect/Rewrite Rules?
  65. Htaccess file isn’t redirecting http sub-pages to https––they display 404 error instead, tried many solutions and none work
  66. How to fix blocked cookies error that doesn’t let me log into wp-admin?
  67. WordPress Multi-Site on Ubuntu 18.04 LAMP Keeps Re-Directing
  68. Good way to block users within a multisite setup without deleting them?
  69. URL without www redirect directly with submission page – Multiwordpress install
  70. Multisite Redirection to new domains
  71. Nginx config, how can I redirect primary multisite domain, but not its sub-folders, nor other domains?
  72. Redirect One Multisite to Another
  73. Site redirecting to http://example.com/wp-signup.php?new=example.com
  74. WordPress Multisite + Erros with URLS and ADMIN
  75. Redirect old uploads after moving to multisite
  76. 301’s not working with multisite
  77. Automatically login user across multisite
  78. Multisite, Subdomain, shared NFS directory Linux HELP
  79. WordPress: how to change URL for individual MultiSites?
  80. How can you override the is_multisite check in wp-login.php for individual login/registration?
  81. How to split existing blog into WordPress Multisites without breaking links?
  82. Multisite Subdomain Redirect Mask
  83. Network Admin URL is shown to anyone before accessing a blog
  84. Cannot use Network Admin (Dashboard) on Multi-site after 301 www redirect
  85. 404 redirecting to home [closed]
  86. Multisite Login problem
  87. How to temporarily redirect front page of a network to one of the sites/blogs?
  88. Https and Http Login Issue on WordPress Multisite
  89. 301 Redirection After Comment
  90. Different Domains in Multisite Setup
  91. Multisite infinite redirect loop
  92. Multisite Redirect for Home Page Only
  93. Disable site visiting and user logins excepting for a specific user
  94. Working with Reverse Proxies and Multisite Installation
  95. How to redirect user after session timeout
  96. Infamous admin login redirect
  97. How to Force WWW. in Domain With WordPress MU Domain Mapping Plugin?
  98. Two installs conflicting – Pages redirecting
  99. Is there something I need to know in order to use WordPress on foreign (Swedish) TLDs?
  100. Restrict users of site 1 to login in site 2 in wordpress multisite
Categories multisite Tags login, multisite, redirect
a child theme not de-registering a patent javascript file
Specific routing for CPT

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress