问题描述
我使用的是XAMPP Zend框架2。我的根(可以是htdocs / zendtest /的.htaccess'),它具有以下code创建.htaccess文件,
I'm using zend framework 2 on xampp. I created .htaccess file in the root('htdocs/zendtest/.htaccess') which has the following code,
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} $ [NC]
RewriteCond %{HTTP_HOST} !/zendtest
RewriteRule ^(.*)$ /zendtest/public/$1 [R=301,L]
我的zentest /公/ htaccess的 code是,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
zentest /公/ index.php的 code:
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
当我打开本地主机/ zendtest在浏览器上,它需要我为本地主机/ zendtest / public'.I要删除公共从URL仅通过设置htaccess的(将工作无论是在本地主机和网络服务器),无需使用虚拟host.how我该怎么办呢?(在孤单本地主机/ zendtest /目录中没有的index.php文件)
when I open 'localhost/zendtest' on browser then it takes me to 'localhost/zendtest/public'.I want to remove 'public' from the url by setting htaccess only(which will work both in localhost and online server),without using virtual host.how can I do that ?(theres no 'index.php' file in 'localhost/zendtest/' directory)
- 谢谢。
修改
更新:的
Update:
目录:
我有以下的.htaccess(据拉维Thapliyal的答案)在zendtest /文件夹(世界上没有'zendtest / index.php文件如今在zendtestfolder.just的.htaccess。所有其他的文件夹结构同为目录的画面。)
I have the following .htaccess (according to Ravi Thapliyal's answer) in the 'zendtest/' folder (theres no 'zendtest/index.php' now in the 'zendtest' folder.just .htaccess. all other folder structures are same as the 'directory' picture.)
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /zendtest/
RewriteCond %{REQUEST_URI} !/public [NC]
RewriteRule ^(.*)$ public/$1 [L]
但如今的以下问题时,打开本地主机/ zendtest /浏览器 -
but it has now the following issue when open 'localhost/zendtest/' on the browser-
解决:的
RESOLVED:
我不得不做出类似下面的画面一些变化(中的.htaccess良好):
I had to make some changes like the following picture (the .htaccess was good):
和实现的目标 -
推荐答案
修改的htdocs / zendtest /的.htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /zendtest/
RewriteCond %{REQUEST_URI} !/public [NC]
RewriteRule ^(.*)$ public/$1 [L]
我不知道什么是 zentest /公/的.htaccess
尝试做,但上面应该重写 / zentest
到 / zentest /公共
透明。现在,就看你的规则公共/的.htaccess
和的index.php
那里。
I'm not sure what's zentest/public/.htaccess
trying to do but the above should rewrite /zentest
to /zentest/public
transparently. Now, it's up to your rules in public/.htaccess
and the index.php
there.
这篇关于如何从URL使用htaccess的本地主机和主机服务器删除“/公众”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!