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 8295751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:43:22+00:00 2026-06-08T14:43:22+00:00

I have a folder structure like Controller |_check.php View |_ .htaccess |_ index.php |_

  • 0

I have a folder structure like

Controller
  |_check.php

View
  |_  .htaccess
  |_ index.php
  |_  Webroot
          |_ js
              |_common.js
.htaccess    

In .htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ View/    [L]
   RewriteRule    (.*) View/$1 [L]
</IfModule>

In View/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

The outer .htaccess file links to View folder and there View/.htaccess links to index.php.

There is button in index.php(view file) with ajax to check.php.

I have given common.js The corresponding ajax function url as

var url = 'check.php'; // OR '../Controller/check.php'

The problem is the ajax is not working properly with two urls.

Whether I need change the folder structure to correct it or do I need to alter any htaccess file for accessing the check.php?

  • 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-08T14:43:24+00:00Added an answer on June 8, 2026 at 2:43 pm

    It’s not about the folder structure but rather the htaccess rewrite rules that are wrong.

    Your htaccess in the “root” redirects all requests to the View folder (which defaults to index.php, I assume)

    I don’t understand what you’re trying to accomplish, if you explain I might be able to help you.

    In your current setup, you can’t access any file besides View/index.php (even when passing GET argument url)

    EDIT:

    In that case, if you wish to View/index.php be the only file accessible and force people to pass through View/index.php file, you can use PHP session variable.

    Something like this…

    in the top of your view.php file:

       session_start();
       $_SESSION['viewCheck'] = true;
       //rest of view.php code
    

    in your check.php code (or the file you’re trying to access via AJAX)

    session_start();
    if (isset($_SESSION['viewCheck']) && $_SESSION['viewCheck'] === true) {
        //Code of check.php
    } else {
        //Error message or redirect to view.php, for instance
    
        //error message example
        header('HTTP/1.0 401 Unauthorized');
    
        //Redirect example
        header("Location: http://www.yourhost.com/View/index.php");
    }
    

    NOTE 1:
    You should remove the rewrite rules of your htaccess files.

    NOTE 2:
    Keep in mind that this is not bullet proof (and can be spoofed) since:

    1. If someone visits View/index.php then he can access check.php freely. This can be mitigated if the session is killed after the ajax request. You can accomplish that if the ajax request consists in 2 requests, for instance, one to get a session key which expires in 10 seconds for instance, and then use that key to obtain the results from check.php

    2. Session can be spoofed too (read more here)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder structure like this: /articles .index.php .second.php .third.php .fourth.php If I'm
If I have a folder structure that looks like this: / /bin/myComponent.cfc /reports/index.cfm How
My folder structure is like - root admin create_page.php pages my_page1.php my_page2.php I have
I have a files structure like this: Class (folder): - User.php - Rule.php Scripts
I have a folder structure like this lots of folders another subfolder _includes getStatisticsTable.php
My codeigniter application directory structure is like --application --htdocs    --index.php    --.htaccess   
I have a folder structure like this: /some_folder /tmp /tmp/foo /tmp/foo/fu * /tmp/bar /tmp/bar/bah
I have folder structure and I would like to create JSON objects based on
In my mvc 3 application, assuming I have a folder structure like \Views\Account\js\custom.js How
I have a folder structure like this below: D:\myphotos\2011-02-09\1.jpg D:\myphotos\2011-02-10\2.jpg .... ...... ............ D:\myphotos\2011-02-23\10.jpg

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.