Zf2更改启动位置

时间:2017-01-09 13:10:36

标签: php .htaccess zend-framework2

我的网络服务器上有zf2,我无法更改Apache中的启动位置。我将.htaccess复制到public_html并在/public/index.php上更改了路径,但我遇到了CSS样式和js的问题。我可以毫无错误地在.htaccess中制作吗?

htaccess的:

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting or installed the project in a subdirectory,
# the base path will be prepended to allow proper resolution of
# the index.php file; it will work in non-aliased environments
# as well, providing a safe, one-size fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}/public/index.php [L]

1 个答案:

答案 0 :(得分:0)

如果你在本地开发环境中,你根本不需要更改@(loggedUser: Option[User], loginInfo: Option[LoginInfo], cards: Seq[Card], addCardInput: AddCardInput)(implicit request: RequestHeader, messages: Messages) @category(card: Card) = { <tr> <td> @b3.form(routes.DeckBuilder.deleteCard()) { @helper.CSRF.formField @b3.submit('class -> "btn btn-primary") { Submit } } </td> </tr> } @views.html.templates.mainApp(Messages("app.title"), tab = "index", loggedUser = loggedUser, loginInfo = loginInfo)) { <h2 class="text-primary">Your Cards</h2> <p class="lead"> @loggedUser.map { user => <div class="modal-body"> <table class="table"> <tbody> @cards.map(grouped => category(grouped)) </tbody> </table> </div> }.getOrElse { @Html(Messages("index.notLogged", routes.Auth.signIn, routes.Auth.startSignUp)) <br/> @Html(Messages("index.resetPassword", routes.Auth.startResetPassword)) } </p> } ,如果你创建一个虚拟主机,就像@bartek_zet所说的那样。

因此,请使用默认的.htaccess文件,并创建一个类似虚拟主机:

.htaccess

ZF2 documentation中的更多信息。