-2

Using htaccess how to change the PHP website default home page ie index.php file from root folder ie "html" to sub folder(say it 'subfolder') but site should still work as before ie the home page will be from 'subfolder' but other pages will still using same old root "html" folder.

NOTE :

  • Website have SSL ie (https)

  • Home page Browser URL should always be https://www.mywebsite.com/

  • root folder is "html".

  • The directory path of "subfolder" is "html/subfolder", this folder only have only one file ie 'index.php'

  • So there should be no change in any page URL (including home page).

  • NO Redirect

0

As per Apache document https://httpd.apache.org/docs/2.4/mod/mod_dir.html, I tried

DirectoryIndex subfolder/index.php

So the Updated root folder .htaccess code is

<IfModule mod_rewrite.c>

Options +FollowSymLinks

RewriteEngine on
RewriteBase /app/

#--------- 
DirectoryIndex subfolder/index.php

#--------- 

RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$ [NC]
RewriteCond %{HTTPS}s ^on(s)|off    
RewriteRule ^(.*)$ http%1://www.mywebsite.com/$1 [R=301,QSA,L]    

RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
RewriteRule ^(.*)&(.*)$ $1__-__$2 [N]

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.