如何从URL使用htaccess的本地主机和主机服务器删除“/公众”?(how can remove '/public' from url using htaccess for localhost and host server)

   IT问题网   2018-11-15 00:00:00

问 题

我使用的是xampp zend框架2。我的根(可以是"htdocs / zendtest /的.htaccess'),它具有以下code创建.htaccess文件,

 选项+了followsymlinks
rewriteengine叙述上
的rewritecond%{http_host} $ [nc]
的rewritecond%{http_host}!/ zendtest
重写规则^(。*)$ / zendtest /公/ $ 1 [r = 301,l]
 

我的"zentest /公/ htaccess的" code是,

rewriteengine叙述上

的rewritecond%{} request_filename -s [or]
的rewritecond%{} request_filename -l [or]
的rewritecond%{} request_filename -d
。重写规则^ * $-[nc,l]

的rewritecond%{request_uri} :: $ l ^(/.+)(+):: \ 2 $
重写规则^(。*) -[e = base:%1]
重写规则^(。*)$%{env:base}的index.php [nc,l]
 

"zentest /公/ index.php的" code:

  php
/ **
*这使我们的生活更轻松,当与路径处理。一切都是相对的
*现在的应用程序根目录。
* /
chdir(目录名(__ dir__));

//设置自动加载
需要'init_autoloader.php";

//运行应用程序!
zend的\的mvc \应用::初始化(需要"配置/ application.config.php') - 运行();
 

当我打开"本地主机/ zendtest"在浏览器上,它需要我为"本地主机/ zendtest / public'.i要删除"公共"从url仅通过设置htaccess的(将工作无论是在本地主机和网络服务器),无需使用虚拟host.how我该怎么办呢?(在孤单"本地主机/ zendtest /"目录中没有"的index.php"文件)

- 谢谢。

修改

更新:

目录:

我有以下的.htaccess(据拉维thapliyal的答案)在"zendtest /"文件夹(世界上没有'zendtest / index.php文件"如今在"zendtest"folder.just的.htaccess。所有其他的文件夹结构同为"目录"的画面。)

 选项+了followsymlinks -multiviews
rewriteengine叙述上
的rewritebase / zendtest /

的rewritecond%{request_uri}!/公共[nc]
重写规则^(。*)$的公共/ $ 1 [l]
 

但如今的以下问题时,打开"本地主机/ zendtest /"浏览器 -

解决:

我不得不做出类似下面的画面一些变化(中的.htaccess良好):

和实现的目标 -

解决方案

修改的htdocs / zendtest /的.htaccess

 选项+了followsymlinks -multiviews
rewriteengine叙述上
的rewritebase / zendtest /

的rewritecond%{request_uri}!/公共[nc]
重写规则^(。*)$的公共/ $ 1 [l]
 

我不知道什么是 zentest /公/的.htaccess 尝试做,但上面应该重写 / zentest 到 / zentest /公共透明。现在,就看你的规则公共/的.htaccess 和的index.php 那里。

标签:如何使用本地主机以及服务器删除公众公家



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

的.htaccess重写规则到路径不改变网址(.htaccess RewriteRule to path without changing URL)

problem so, i've this problem: base website located at ...

我怎样才能mod_rewrite的,并保持查询字符串?(How can I mod_rewrite and keep query strings)

problem i want to mod_rewrite a url to another page, but ...

如何从PHP脚本改变外观的URL(How to change appearance of URL from within a PHP script)

problem i have some php and html in the same file, and i ...

删除尾随的问号htaccess的(Removing trailing question mark with htaccess)

problem can someone help me understand this code # remov ...

URL重写GET参数(URL Rewrite GET parameters)

problem i want my url to look like the following www.web ...

htaccess的从XAMPP转向灯开的Ubuntu 13.10后不工作(启用htaccess的Apache中的Linux服务器)(htaccess is not working after moving from XAMPP to LAMP on ubuntu 13.10 (Enable htaccess in apache linux server))

problem my codeigniter project is running successfullyon ...

查询字符串和放大器;国防部重写(Query Strings & Mod ReWrite)

problem i'm not too inexperienced with rewrite (not a mas ...

在.xml文件PHP的错误?(PHP error in .xml file)

problem ok firstly, i added this line to my .htaccess fil ...

使用Apache的mod_rewrite解析搜索引擎友好的URL(using apache's mod_rewrite to parse SEO friendly URL's)

problem how do i convert something like me.com/profile/2 ...

搜索引擎友好的URL(Search-Engine Friendly URLs)

problem i am working on building my first search-engine f ...

斜杠之后将文字与.htaccess的变量(Turn text after slashes into variables with HTACCESS)

problem i need to pass 3 variables with a url but using s ...

从URL删除字符与htaccess的(Remove Characters from URL with htaccess)

problem hopefully someone can see what i'm do ...

重定向所有的HTML扩展到.PHP(redirect all .html extensions to .php)

problem i want to update all the pages on a website to us ...

需要转义#(哈希/磅)字符在.htaccess重写规则(need to escape # (hash/pound) character in .htaccess rewrite rule)

problem the question is fairly simple but i w ...

如何使用的.htaccess重写规则改变下划线以破折号(How do I use .htaccess RewriteRule to change underscores to dashes)

problem i'm working on a site, and its cms used to save n ...

请求实体太大PHP(Request Entity Too Large PHP)

problem in one of my cakephp site, i got this error. req ...

的.htaccess使用PHP $ _GET缩短网址(.htaccess shorten URL using php $_GET)

problem i need to be able to shorten my page from: mydom ...

Gzip已融为一体pression通过的.htaccess不工作(Gzip compression through .htaccess not working)

problem i have been creating a site and checking it's spe ...

重定向www.subdomain.example.com到subdomain.example.com(redirecting www.subdomain.example.com to subdomain.example.com)

problem i've had some users trying to access a site that ...

添加尾随斜线的.htaccess(Add Trailing Slash .htaccess)

problem i'm trying to get the following effec ...