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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:23:12+00:00 2026-05-22T23:23:12+00:00

I have a website in PHP, and I’m trying to hide the extension. I’ve

  • 0

I have a website in PHP, and I’m trying to hide the extension. I’ve found a couple of things via Google, but they all seem to be too complicated, or they redirect index to index.php: like if you write name.com/contact it goes to name.com/contact.php. I don’t want that, I just want:

    www.name.com/es/index.php       to be www.name.com/es/inicio
    www.name.com/es/empresa.php     to be www.name.com/es/empresa
    www.name.com/es/productos.php   to be www.name.com/es/productos
    www.name.com/es/clientes.php    to be www.name.com/es/clientes
    www.name.com/es/recetas.php     to be www.name.com/es/recetas
    www.name.com/es/contacto.php    to be www.name.com/es/contacto

    www.name.com/en/index.php       to be www.name.com/en/home
    www.name.com/en/company.php     to be www.name.com/en/company
    www.name.com/en/products.php    to be www.name.com/en/products
    www.name.com/en/clients.php     to be www.name.com/en/clients
    www.name.com/en/recepis.php     to be www.name.com/en/recepis
    www.name.com/en/contact.php     to be www.name.com/en/contact

the /en/ folder is English version and the /es/ folder is the Spanish version

Also the links inside the website, would be also without the extension.

E.g, an image linked to clientes would be clientes and not clientes.php and if somebody tries to go to /page.php, it still works but it redirects to /page.

  • 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-22T23:23:13+00:00Added an answer on May 22, 2026 at 11:23 pm

    The htacces file should look like this:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    

    You redirect any php file in the url with the same name withouth the “php”.
    Then in your php files, you can check to see if the url contains the extension (http://blabla.com/bla.php) and redirect the page to the same one withouth the extension.
    So, at the beginning of each php file you should call this function :

    function redirectIfNeeded(){
        $url = $_SERVER["REQUEST_URI"];
        if(preg_match("/\.php/$", $url))
            header("Location: ".preg_replace("/\.php/",$url));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP website backed by a MySQL database and a small team
I have a website built in PHP 4 with a framework made by hand
I have a website which uses PHP and HTML pages, I want to create
I have a prototype website written in PHP. Lately i've rewritten code to separate
I have a website which uses the custom 404 error handling in PHP/Apache to
I'm developing a website in PHP and I have large JS files that I
Is it possible to check who is entering your website in PHP. I have
I have been using PHP and JavaScript for building my dad's website. He wants
I'm writing multilingual website. I have several files on server like: /index.php /files.php /funny.php
I have a PHP website I'm maintaining and I've confirmed that this worked at

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.