Redirect the browing directory to homepage in core php?

Bilal shafi 21 Reputation points
2021-11-21T12:56:05.063+00:00

I have a website that is built in the CORE PHP. When added " Option-indexes " my directory browsing file was hidden. Now i want that when someone open the " BROWSING DIRECTORY " then i will automatically redirect to my home page?

Can anyone help me?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,945 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2021-11-23T18:13:01.28+00:00

    Hi @Bilal shafi ,

    I'm not familiar with CORE PHP but I think all you would need is a .htaccess file that contains rewrite rules.

       <IfModule mod_rewrite.c>  
           RewriteEngine on  
           RewriteCond %{REQUEST_URI} ^(.*)  
           RewriteRule ^my-old-url.html$ /my-new-url.html [R=301,L]  
       </IfModule>  
    

    If CORE PHP is based of PHP 8, then for App Service, you will need to use rewrite rules for nginx as PHP 8 runtime is no longer based on Apache, see https://azureossd.github.io/2021/09/02/php-8-rewrite-rule/.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.