嗯,我有一个共享主机,但没有 ssh 访问权限。问题是服务器结构和symfony结构......
服务器有这样的结构
错误/ 日志/ ... 网络/
在 Web 目录中我们可以加载 Web 应用程序。 Symfony 结构是..
应用程序/ .. 网络/
问题是,对于我的域名,如果我尝试访问,我必须输入 www.domainname.com/web/ 才能在 Symfony 项目中访问....
如果我尝试将所有 Web Symfony 内容复制到 Web 目录,它会渲染第一页正常(index.php),但链接错误,因为它们是 www.domainame.com/moduleName/ 并且该目录不存在...
如果我在 Web 域目录中创建 .htacces 文件...当我输入 www.domainname.com 时,它会将我重定向到 Web 自动,但其他链接中包含 www.domainname.com/web/moduleName/他的方向
我只想要www.domainname.com/moduleName/..。我怎样才能做到呢?
这是我的.htaccess 文件:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ web/index.php [QSA,L]
</IfModule>
另一个相关问题:
..
/web/
app/
...
web/
/blog/
如果我修改这个,我在访问我的/blog/目录时会遇到问题?
.htaccess mod_重写
为了从 url 中删除 /web,您需要使用一个名为 mod_rewrite 的 apache 模块。像这样:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
相关文档位于此处。
设置 symfony 的正确方法是使用指向 Web 文件夹的虚拟主机。这将使用 Web 文件夹作为您的根目录,因此您不会在网址中看到它。