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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:30:18+00:00 2026-06-15T04:30:18+00:00

I have a directory site and its sub-folder and files in it. It also

  • 0

I have a directory site and its sub-folder and files in it.
It also contain a .htacess and below is the code

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?cc=$1

so my below url will is effective and working good.

http://localhost/site/sweetinc

And below code in index.php below

<?php
if (isset($_GET['cc']) and !empty($_GET['cc'])) {
    echo $_GET['cc'];
} else {
    die("Sorry wrong code");
}
?>

And this is working good.

Now, i want to access or display all files as normally

http://localhost/site/sweetinc/home.php
http://localhost/site/sweetinc/test.php

home.php and test.php are located in site directory. And if it redirects to other sub-folders then it should
be visible like

http://localhost/site/sweetinc/sub-folder1/test3.php

Is this possible, as I am working seperating a group using seperate directory using .htaccess and considering all files in site directory as base files

enter image description here

  • 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-15T04:30:19+00:00Added an answer on June 15, 2026 at 4:30 am

    The trick here (if I understand your question correctly) is that you don’t want the rewrite rule to be in effect when you’re trying to reach a file that actually exists, right?

    In that case, just before your RewriteRule, add these lines:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    That way, the rewriterule only takes effect when the url (/site/sweetinc for example) does not really exist on the server. If it does (/site/sweetinc/home.php) the rewriterule is skipped and the file is shown.

    (-f checks if the filename exists, -d checks if the directory exists, so /home/sweetinc/somedir/ should work too)

    Update based on updated question
    You need two separate rules for this. First of all, if the /sweetinc/ directory in the url is used, refer them to the /site/ folder:

    RewriteRule ^sweetinc/(.*)$ /$1 [L]
    

    Then, if the file does not actually exist, let the index.php handle it:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?cc=$1 [L]
    

    Some examples:

    I have the following files in my files subdomain:

    • /index.php (which has the same content as yours does, so it reads out ?cc=
    • /circle3.PNG
    • /the .htaccess with the above rules

    http://files.litso.com/sweetinc/hello shows the index.php that echoes “hello”
    http://files.litso.com/sweetinc/circle3.PNG shows the actual file in /

    (note, I don’t have a /sweetinc/ directory, it’s all faked)

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

Sidebar

Related Questions

I have a MOSS web site with its virtual directory in IIS. That VD
I have a site that has a /sites/default/files/ directory where user content is typically
I have a folder in the root directory of a wordpress site. As such,
I have a web site http://www.mydomain.com Here I have created a sub folder http://www.mydomain.com/products
I have uploaded a site built with asp.net 2.0 in a sub directory created
Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub
Possible Duplicate: PHP: let a file return its own directory. Hi I have a
I have my php in /srv/www/site directory, which resolves to www.domain.com/site . How can
I have a directory structure as follows Client_Site/ some_folder1/ some_folder2/ some_folder3/ Lots of files
I have many static images under a directory in my site structure, and I'm

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.