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

  • Home
  • SEARCH
  • 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 6830183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:35:17+00:00 2026-05-26T22:35:17+00:00

I want the following: www.bla-bla.com/ –> www.bla-bla.com/php/index.php www.bla-bla.com/php/index.php –> www.bla-bla.com/php/error.php I have tried the

  • 0

I want the following:

  1. www.bla-bla.com/ –> www.bla-bla.com/php/index.php
  2. www.bla-bla.com/php/index.php –> www.bla-bla.com/php/error.php

I have tried the following but doesn’t work

RewriteEngine on
RewriteRule ^/?$  /php/index.php [S=1]
RewriteCond %{REQUEST_URI} =/php/index\.php
RewriteRule (.*)? /php/error.php [R=404]

What can I do to deny access from real path?


URL=http://localhost
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/ -> 
 (3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri ''
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/ -> 
 (3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri ''
 (2) [perdir C:/xampp/htdocs/] rewrite '' -> '/php/index.php'
 (1) [perdir C:/xampp/htdocs/] internal redirect with /php/index.php [INTERNAL REDIRECT]
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
 (3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri 'php/index.php'
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
 (3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri 'php/index.php'
 (1) [perdir C:/xampp/htdocs/] pass through C:/xampp/htdocs/php/index.php
URL=http://localhost/php/index.php
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
 (3) [perdir C:/xampp/htdocs/] applying pattern '/php/index\.php' to uri 'php/index.php'
 (3) [perdir C:/xampp/htdocs/] strip per-dir prefix: C:/xampp/htdocs/php/index.php -> php/index.php
 (3) [perdir C:/xampp/htdocs/] applying pattern '^(/?)$' to uri 'php/index.php'
 (1) [perdir C:/xampp/htdocs/] pass through C:/xampp/htdocs/php/index.php

Options +FollowSymlinks
RewriteEngine on

RewriteRule /php/index\.php /php/error.php [L]
RewriteRule ^(/?)$ /php/index.php [QSA,L]

Wtf is going on 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-05-26T22:35:17+00:00Added an answer on May 26, 2026 at 10:35 pm

    Try this:

    # If the actual request is for /php/index.php, rewrite to error.php
    RewriteCond %{THE_REQUEST} ^[A-Z]+\ /php/index.php  [NC]
    RewriteRule ^php/index\.php /php/error.php  [L]
    
    # Otherwise check if root request and rewrite to /php/index.php
    RewriteRule ^$ /php/index.php  [L]
    

    EDIT: responding to comments:

    Without the[L] flag, it will try to apply the next rule. mod_rewrite will always send it back through the rewrite engine after a URI has been rewritten. It will continue to do so until the URI went through the engine unchanged. The first condition checks that the actual request is for /php/index.php, so that the rewritten URI won’t match. Example:

    1. Someone requests http://bla-bla.com/
    2. first rule doesn’t match because the HTTP Request is GET / HTTP/1.1
    3. second rule rewrites to /php/index.php
    4. mod_rewrite sends the rewritten URI back through the rewrite engine
    5. first rule doesn’t match because eventhough the URI is now “/php/index.php”, the original HTTP Request is still the same: GET / HTTP/1.1
    6. second rule doesn’t match because the URI is now “/php/index.php” and not “/”.
    7. rewrite engine stops because base URI is unchanged.

    Example 2:

    1. Someone requests http://bla-bla.com/php/index.php
    2. first rule matches because the HTTP Request is GET /php/index.php HTTP/1.1
    3. URI is rewritten to /php/error.php
    4. second rule doesn’t match
    5. URI is sent back through the rewrite engine
    6. first rule’s condition matches because the HTTP Request is still the same
    7. however, the URI isn’t ‘/php/index.php’ now so the actual rule doesn’t match
    8. second rule still doesn’t match
    9. reiwrte engine stops because base URI is unchanged.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic page that looks like the following: www.sitedomain.com/page.php?id=30&name=about_our_company I want to
I want to redirect the following http://www.example.com/folder/index.php?dir=Dir1 http://www.example.com/folder/index.php?dir=Dir1/Dir2 to http://www.example.com/folder/Dir1 http://www.example.com/folder/Dir1/Dir2 I want to
I have the following page: www.domain.com/index.php?route=information/contact and I'd like to rewrite it so that
Consider the following scenario: http://www.restserver.com/example.php returns some content that I want to work with
I have following url: www.example.com/index.php/search/search_data/Doctor:a/Gender:Male/Language:Urdu/ and I want to convert it to associative array
Say I have the following file: http://www.example.com/images/folder/image.jpg I want to serve it on http://s1.example.com/folder/image.jpg
I'm have the following URL : www.example.com?arg1=foobar I want to get the arg1 value.
I have the following for www.domain.com and login.domain.com . But spammers forward there site
I want the following url http://www.mydomain.com/user.php?id=username to http://www.mydomain.com/username via .htaccess... i also want to
I have the following URL: www.exampe.com/id/1234 and I want a regex that gets the

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.