skip to Main Content

I have following folder structure in apache server.

Public_html
-->admin
    --->admin_login.php
-->website
    --->index.php

since the index.php inside the website folder,
i have given following code in .htaccess

RewriteCond %{REQUEST_URI} !^/website/
RewriteRule ^(.*)$ /website/$1 [L,NC]

so that the when the user enter root url , it will appear "www.myurl.com" instead of "www.myurl.com/website/"

but the issue is, i could not be able to access admin_login.php.

is there anyway to modify .htaccess, to come website/index.php in main url and able to access admin_login.php(both)?

Thanks in Advance

2

Answers


  1. With your shown samples and attempts please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs.

    RewriteEngine ON
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^index.php/?$ website/index.php [QSA,NC,L]
    
    Login or Signup to reply.
  2. You need to add an exception to existing rule like this:

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/(website|admin)/ [NC]
    RewriteRule .* website/$0 [L]
    

    Negative condition %{REQUEST_URI} !^/(website|admin)/ will match every URI except URIs that start with /website/ or /admin/. This will allow you to directly open www.myurl.com/admin/admin_login.php.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search