简体   繁体   English

子url中的CakePHP(不是子目录)

[英]CakePHP in sub-url (not sub-directory)

I can find dozens of articles on installing CakePHP in a sub-directory and getting it to appear in the root url. 我可以找到几十篇关于在子目录中安装CakePHP并让它出现在根URL中的文章。 That is NOT what I am asking for. 不是我要求的。 I rarely down-vote, but if you give that answer, I will down vote you. 我很少投票,但如果你给出答案,我会投票给你。

I have CakePHP in my root directory on my hosting server. 我的托管服务器上的根目录中有CakePHP。 It's a clean Apache server instance... I think. 这是一个干净的Apache服务器实例......我想。 I'm really not a server guy. 我真的不是服务员。 I created a new account through WHM on Hostgator and have CakePHP sitting in the public_html. 我在Hostgator上通过WHM创建了一个新帐户,并将CakePHP放在public_html中。

However, there is no domain name associated with this server yet. 但是,尚未与此服务器关联的域名。 The URL is like this: URL如下所示:

http://123.456.0.0/~example/

And CakePHP gives me the following errors: 而CakePHP给了我以下错误:

Error: ~exampleController could not be found.

Error: Create the class ~exampleController below in file:
app/Controller/~exampleController.php 

I imagine there's some .htaccess configuration that makes it ignore that /~example in the URL. 我想有一些.htaccess配置使它忽略了URL中的/~example Can someone point me in the right direction, even if it's just the right page in the CakePHP docs? 有人能指出我正确的方向,即使它只是CakePHP文档中的正确页面吗?

By partially following the advice at http://bakery.cakephp.org/articles/syl-via/2011/09/19/rewritebase_config_for_cake_installation_with_userdir_and_mod_rewrite I was able to make this work by adding the following to the .htaccess file in the root of the Cake install: 通过部分遵循http://bakery.cakephp.org/articles/syl-via/2011/09/19/rewritebase_config_for_cake_installation_with_userdir_and_mod_rewrite中的建议,我能够通过将以下内容添加到根目录中的.htaccess文件来完成此工作。蛋糕安装:

RewriteBase /~example

I put this after RewriteEngine on for it to work. 我把它放在RewriteEngine on 之后才开始工作。

In other words, if your Cake install is at /home/example/ then it's the /home/example/.htaccess file that you'd change. 换句话说,如果你的Cake安装位于/home/example/那么它就是你要更改的/home/example/.htaccess文件。

I didn't edit app/.htaccess or app/webroot/.htaccess because it seems to work without these files needing to be edited. 我没有编辑app/.htaccessapp/webroot/.htaccess因为它似乎没有这些文件需要编辑。

Please note that I tested this with the latest version of Cake (2.3.5) -- I don't know if it will work the same way in older versions. 请注意,我使用最新版本的Cake(2.3.5)对此进行了测试 - 我不知道它是否会在旧版本中以相同的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM