habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Htaccess Redirect to Sub Folder Laravel Project

48 sec read

Htaccess-Redirect-to-Sub-Folder

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.

htaccess redirect sub folder
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.


See also  Install Apache PHP-FPM Centos 7
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox