php - 如何从laravel子文件夹中的url中删除public
问题描述
我想将我的 laravel 网站托管在如下子文件夹中:-
public_html/ecommerce/
实际上,我在 public_html 中还有一个 laravel 网站,因为我已经从 htaccess 下面的 url 中删除了 public
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
但是如果在 public_html/ecommerce 中添加相同的 htaccess 它根本不起作用,因为它可能是由于子文件夹
我在谷歌上搜索了一些人告诉以下几点: -
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.
任何人都可以帮助我如何仅在 htccess 级别上做。提前致谢
解决方案
你的目录结构必须是,
public_html
- laravel_app1
- laravel_app2
- laravel_app3
在每个 laravel 应用根目录下创建 .htaccess 即 laravel_app1/.htaccess、laravel_app2/.htaccess 等。在每个 .htaccess 中添加这样的规则
<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
最后你可以访问网站,yourdomain.com/laravel_app1 yourdomain.com/laravel_app2 等等
推荐阅读
- python - 将相关对象渲染到模板中
- php - 如何从多维数组中制作一个好的 html 表示表?
- sql - 需要帮助编写查询 Oracle SQL
- python - 如何在 Tensorflow 中使用 keras 在 2 个 GPU 之间拆分模型?
- object-detection - TensorFlow Faster RCNN 配置文件中的 image_resizer 是什么意思
- swift - 分别展开每个 collectionView 单元格
- json - 为什么存储在我的 json 文件中的值没有改变?
- python - 挑战:TSP 问题和找到正确的最小化点顺序
- ruby-on-rails - Ynaqdhm 的含义?
- javascript - 从 PowerShell 脚本执行 Nodejs 脚本