Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:04:16+00:00 2026-06-15T01:04:16+00:00

I am having an issue with my .htaccess file. It is redirecting everything through

  • 0

I am having an issue with my .htaccess file. It is redirecting everything through my index.php page which is what I want for the majority of requests.

BUT the only time I do not want to redirect is via an AJAX call.

It redirects any request through my index.php file like so:
RewriteRule /.* /index.php [NC,L]

The AJAX request url is:
http://myurl.dev/login/ajax/functions.php

With the directory structure:
/modules/login/ajax/functions.php

I am inexperienced with regex and RewriteRules, and have read / tried many variations with varying logic but cannot stop anything from /ajax/ to not redirect to the index page.

I have tried a RewriteCond before the Index RewriteRule to redirect to index unless /ajax/ but no luck.

Rewrite Cond %{REQUEST_URI} !(.*)/ajax
RewriteRule /.* /index.php [NC,L]

Also tried a seperate RewriteRule for the /ajax/ request:
RewriteRule ^(.*)/ajax/functions\.php$ /modules/$1/ajax/functions.php [NC,L]

So nothing as worked so far, it either redirects to the index or hits a 500 server error.

Does anybody have any suggestions or links to help? Thanks.

Note: When I say redirect, I do not mean a full page refresh as I know that Apache wont do a full url refresh without the [R] flag.

— Edit: Working file —

Here is my full .htaccess code:

Options +FollowSymLinks  
RewriteEngine on

# Intercept any requests to the core, and keep them being written to the core (so they don't go to index.php)
RewriteRule ^core/(.*)$ core/$1 [NC,L]

# The magic, stops any requests to a file for being redirected.
# needed to be under the /core/ redirect
RewriteCond %{SCRIPT_FILENAME} !-f

# Rewrite all requests to index.php.
RewriteRule /.* /index.php [NC,L]

# Some requests (without trailing slashes) can fall through the above rule. This bit catches those stragglers.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]

ErrorDocument 404 /404/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:04:17+00:00Added an answer on June 15, 2026 at 1:04 am

    Use

    RewriteCond %{SCRIPT_FILENAME} !-d //excludes existing directories
    RewriteCond %{SCRIPT_FILENAME} !-f //excludes existing files
    

    before any RewriteRule . This will exclude any directory or file which already exists, so the RewriteRule won’t work on http://myurl.dev/login/ajax/functions.php, because it actually exists, but it will work on http://myurl.dev/someOtherNonExistantFile.php

    That makes this your full .htaccess file code:

    AuthType Basic
    Options +FollowSymLinks  
    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    # Intercept any requests to the core, and keep them being written to the core (so they don't go to index.php)
    RewriteRule ^core/(.*)$ core/$1 [NC,L]
    
    # Rewrite all requests to index.php.
    RewriteRule /.* /index.php [NC,L]
    
    # Some requests (without trailing slashes) can fall through the above rule. This bit catches those stragglers.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ /$1/ [L,R=301]
    
    ErrorDocument 404 /404/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having issues removing index.php? from the URL: http://localhost/index.php?/reset_password With htaccess file: # Customized error
Im having a weird issue here; The following .htaccess works but now (after changing
I am having an issue with using an .htaccess file to rewrite my urls
i'm having a little issue with modrewrite under php. this is inside my .htaccess
I am having issue passing get variables. index?p=calendar refers to calendar.php located in pages/calendar.php
I'm having a really strange issue with a redirect in my .htaccess. The rule
I am having issue when sending data from Service to Activity through Notification ,
I am having issue with a wordpress Tag CLoud Plugin. I want to show
Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point
I'm having issues in writing rewritecond in the htaccess file on my web server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.