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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:25:03+00:00 2026-05-23T06:25:03+00:00

1) I would like to create a rewrite rule that removes the file at

  • 0

1) I would like to create a rewrite rule that removes the file at the end of the URL if the file extension is PHP or (S)HTM(L). For example:

This: http://www.example.com/index.php
Becomes: http://www.example.com/

This: http://www.example.com/index.php?action=login
Becomes: http://www.example.com/?action=login

2) I would like to set up some URL redirect with my .htaccess so that if someone browse a certain path is automatically redirected to /index.php. For example:

This: http://www.example.com/classes/(index.php)
Redirected To: http://www.example.com/(index.php)

This: http://www.example.com/classes/class.php
Redirected To: http://www.example.com/(index.php)

This: http://www.example.com/classes/style.css
Redirected To: http://www.example.com/(index.php)

Any clue about it?
Many thanks!

  • 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-23T06:25:04+00:00Added an answer on May 23, 2026 at 6:25 am

    For 1) you may invert your question, the job of mod-rewrite is to read dirty url and find the real file, so what you want is to use a false url (without index.php) and that mod-rewrite finds the index.php. Mod-rewrite will not modify your url, it’s your application code job (PHP?).

    So let’s say your application is writing this url:

    http://www.example.com/
    

    The fact that apache will use

    http://www.example.com/index.php
    

    or

    http://www.example.com/index.htm
    

    or

    http://www.example.com/index.html
    

    to respond is not handled by mod-rewrite but simply by the Apache configuration directive

    DirectoryIndex index.php,index.htm,index.phtml
    

    For http://www.example.com/?action=login it should also work.

    For 2): well it’s unclear. Do you always want to redirect people trying to access your classes directory? Then 2 things:

    1. If this directory should’nt be accessed from the web put it outside of the web directory, nobody will see it, and if it only contain php classes PHp can include files which are not on the web directory. If it contains css and js files then it’s an error, redirecting them in the root will certainly not give them a js or a css
    2. You do not need mod-rewrite to make simpel redirect, mod_alis, which is a module that you certainly have (99% of chances) procides the Redirect and RedirectMatch keywords so that you can write:

      RedirectMatch permanent /classes/.* http://www.example.com/

    as always check this page: for rules that can be done easily without entering in the brain convolutions of mod-rewrite.

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

Sidebar

Related Questions

I would like create URL rewrite rule that will set default document for my
I would like to create rewrite rules in my .htaccess file to do the
I would like to use the URL Rewrite module of IIS7 to create 301
I would like to create a COM object that runs in an out of
I would like to create a stored procedure with parameters that indicate which fields
I have a directory named dollars that contains a file index.php . I would
I am trying to create a rewrite rule that accomplishes two things: Redirect (www.)?domain.com
I have a site that currently serves results as example.com/index.php?show=foo and I'd like it
I am new to the URL rewrite rules and would like to rewrite some
i would like create a array of structure which have a dynamic array :

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.