Nginx and htaccess Redirect Issues

htaccess & Redirects | Updated March 2026

If your .htaccess redirects aren't working for specific directories, or a folder keeps redirecting to the wrong place, it may be caused by the nginx reverse proxy that runs in front of Apache on our servers. Nginx handles static files and caching, while Apache handles PHP and .htaccess rules. In some cases, nginx intercepts a request before Apache sees it, bypassing your .htaccess rules.

01. How Nginx + Apache Work Together

Our servers run a dual-layer web server architecture:

  • Nginx (front layer) - handles incoming connections, serves static files (images, CSS, JS, HTML), SSL termination, and caching
  • Apache (back layer) - handles PHP processing, .htaccess rules, and dynamic content

When a visitor requests a page, nginx checks if the request is for a static file. If so, nginx serves it directly without involving Apache. If the request needs PHP processing, nginx passes it to Apache, which reads .htaccess and processes the request.

This is why .htaccess redirects work for PHP pages but may not work for static files or directory-level redirects.

02. Common Redirect Issues

Directory Redirect Not Working

If you have a redirect in .htaccess for a directory (e.g., /old-folder/ to /new-folder/) and the directory contains an index.html, nginx may serve the index.html directly without consulting Apache's .htaccess.

Subdomain or Folder Pointing to External Server

If you want a folder like yourdomain.com/app/ to proxy to a different server, .htaccess ProxyPass directives won't work on shared hosting. This requires server-level nginx configuration.

Redirect Loops

If both nginx and .htaccess try to redirect the same URL, you can get infinite redirect loops. This shows as a "too many redirects" error in the browser.

03. How to Fix

For PHP-Based Redirects (Most Cases)

If the redirect involves PHP pages (WordPress, etc.), .htaccess works normally. Make sure your redirect rules are correct using our .htaccess guide or redirect guide.

For Static File or Directory Redirects

If .htaccess redirects aren't being applied to static files or directory URLs, open a support ticket. We can add the redirect at the nginx level, which takes priority over everything.

For Redirect Loops

Check for conflicting redirects in:

  • Your .htaccess file (may have duplicate or circular rules)
  • cPanel > Domains > Force HTTPS Redirect (may conflict with .htaccess HTTPS redirect)
  • WordPress Settings > General (site URL mismatch)
  • Cloudflare (if using "Always Use HTTPS" on top of server-side redirect)

Need a Server-Level Redirect?

If your redirect requires nginx configuration, open a ticket with the source URL, destination URL, and redirect type (301 permanent or 302 temporary).

Open a Support Ticket

Quick Recap

  1. Nginx serves static files, Apache handles PHP - .htaccess only affects Apache requests
  2. PHP page redirects work in .htaccess - no changes needed
  3. Static file/directory redirects may need nginx config - contact support
  4. Redirect loops - check for conflicting rules in .htaccess, cPanel, WordPress, and Cloudflare
  5. ProxyPass not available - requires VPS or server-level configuration

Last updated March 2026 · Browse all htaccess articles · See also: .htaccess Guide | 302 Redirects

  • 163 Users Found This Useful

Was this answer helpful?

Related Articles

301 Redirect

This code will redirect all visitors who attempt to access the old-url.html page to the...

Disable error_log via htaccess

Disabling error_log Files via .htaccess   If your error_log file is growing large and...

Create a 410 Redirect for Missing Files

Creating a 410 Gone Redirect for Removed Pages   A 410 response tells search engines that a...

Redirect http to https and www

To forward a website to use both www. and https:// use the following in an .htaccess file:...

htaccess referral redirect

Setting Up a Referral Redirect With .htaccess   A referral redirect (also called a...



Save 30% on web hosting - Use coupon code Hosting30