Pau*_*non 3 php apache .htaccess mod-rewrite shared-hosting
我目前在共享服务器上使用Silex框架托管网站,但是我遇到了问题...
Silex就像Synfony,在/ web /子文件夹中有一个app.php文件:然后只能通过URL website.com/web/访问该网站。我无法创建虚拟主机,因为它是共享服务器,因此我认为解决方案是使用.htaccess文件...
我设法自动将website.com重定向到website.com/web/,但是我不太喜欢这个选项;我希望website.com直接指向website.com/web/,但是我不知道如何仅使用htaccess文件来做到这一点。我已经尝试解决这个问题了好几个小时了,这真使我丧命...
目前,我使用此文件:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ web/app.php [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
但这只是将您从website.com重定向到website.com/web
无论如何,我可以使用htaccess文件使根url直接指向/ web文件夹吗?
非常感谢你 :)
如果您只想通过输入http://example.com来访问http://example.com/ 子目录,则应该可以使用。
# .htaccess main domain to subdirectory redirect
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/ [L]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2281 次 |
| 最近记录: |