【发布时间】:2023-04-03 23:45:02
【问题描述】:
我不经常在 SOF 上提问,因为我通常只在 SOF 上搜索就能找到答案。这一次对我来说太难了!我对htaccess没有很多经验。其实我没有太多经验,现在离开学校 6 个月了!
我正在使用 Wordpress 4.9.8 和 Laravel 5.7 进行个人项目。 Wordpress 将用作入口点和文章部分,Laravel 将用作应用程序部分以显示来自数据库的大量信息。
我正在使用 Xampp 和 MySql Workbench 进行本地开发。
我正在使用虚拟主机来模拟域名。
项目在根文件夹中的结构如下:
- Wordpress 文件夹和文件
- htaccess
- Laravel 文件夹
- 来自 Laravel 的所有文件夹和文件
- 公开
- htaccess
项目网址是这样的:
- dev.domain.com/ -->Wordpress 部分
- dev.domain.com/plants/public --> Laravel 部分
我只需要隐藏 URL 的 "public" 文件夹,并且仍然可以访问该目录。 到目前为止,我能够使用 htaccess 直接跳过 Laravel 的根文件夹进行重定向。
- dev.domain.com/plants 到 dev.domain.com/plants/public
在尝试了所有我认为有意义但不确定到底该放在哪里的东西之后,我似乎无法将手指放在上面。在项目的根目录下还是在这部分的公共目录中?
这是我在项目根目录中的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} ^/plantes [NC]
RewriteRule . plantes/public [L]
</IfModule>
我在公用文件夹中有什么:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
-- Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
-- Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
-- Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
感谢您的帮助或提示!
【问题讨论】:
标签: wordpress laravel url-rewriting