Hi Dude, today is beautifull day. This post simply explain about htaccess redirect to sub folder in apache web server. Redirect is one of function htaccess.
Case Study Htaccess Redirect to Sub Folder
I have finished deploying laravel project which is installed in the root directory /var/www/html/demo-fa. Index laravel project is under folder /public
Problem
The problem is i want to redirect from /demo-fa to /demo-fa/public.
Here is example script htaccess that redirect /demo-fa to /demo-fa/public.
admin@server ~ pwd
/var/www/html/demo-fa
Create .htaccess file in root directory of web that defined in virtualhost apache. I am set root directory in virtual host to /var/www/html/demo-fa.
vim .htaccess
Fill with code below.
####
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/demo-fa/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /demo-fa/public/$1
#RewriteRule ^ index.php [L]
RewriteRule ^(/)?$ demo-fa/public/index.php [L]
##favicon
RewriteRule ^favicon\.ico$ /demo-fa/public/favicon.ico [L]
####
Favicon laravel also redirect.
See Also: Ispconfig Nginx Directives Laravel
That is short article about htaccess redirect to sub folder. May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it. Or if there is another method to redirect with htaccess, you can also add it in the comments, I will mention you and add a backlink to your website.