简体   繁体   中英

How to remove public from url in sub folder in laravel

I want to host my laravel website in subfolder like below:-

public_html/ecommerce/

Actually i have one more laravel website in public_html for that i have removed the public from url frorm below htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$    public/    [L]
RewriteRule    (.*) public/$1    [L]
</IfModule>

But if add same htaccess in public_html/ecommerce its not working at all beacause its may be due to sub folder

I have searched on google some one told below points:-

1) Rename server.php to index.php 
2) copy .htacces from public to root
 This is working but my all assets path like css jss are not fetching for that i need to add public in each asset link.

Can anybody help me how can i do in htccess level only. Thanks in advance

your directory structure must be,

public_html

  • laravel_app1
  • laravel_app2
  • laravel_app3

in each laravel application root directory create .htaccess that is, laravel_app1/.htaccess, laravel_app2/.htaccess and so on. In each .htaccess add rules sth like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

finally you can access website as, yourdomain.com/laravel_app1 yourdomain.com/laravel_app2 and so on

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM