GoDaddy 上的 Cakephp htaccess mod_rewrite

发布于 2024-09-08 07:06:35 字数 1469 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2024-09-15 07:06:35

如果我理解正确的话,您可以从以下位置访问您的应用程序:

# http://example.com/cakephp/*   # normally served from html/cakephp/

... 但您希望 URL 显示如下:

# http://example.com/*           # normally served from html/

最简单的选择是将 cakephp 目录中的所有文件和文件夹向上移动一个级别,因为它旨在“开箱即用”,因此目录结构如下所示:

# html/.htaccess               <- this file would then ...
# html/app
# html/app/.htaccess
# html/app/webroot             <- ... rewrite requests to here
# html/app/webroot/.htaccess
# html/cake

如果您希望保留包含目录的 cakephp,那么您将需要添加自己的 .htaccess 文件复制到 html/ 目录,告诉 Apache 您的意图。结构如下:

# html/.htaccess               <- your .htaccess file goes here
# html/cakephp/.htaccess       <- it should look similar to this one
# html/cakephp/app
# html/cakephp/app/.htaccess
# html/cakephp/app/webroot     <- you need to rewrite requests to here
# html/cakephp/app/webroot/.htaccess
# html/cakephp/cake

可以从第一个 CakePHP .htaccess 文件复制其中的内容(如上所述)并稍作更改以产生您想要的结果。像这样的东西:

RewriteEngine on
RewriteRule ^$   cakephp/app/webroot/   [L] # rewrites requests to example.com/
RewriteRule (.*) cakephp/app/webroot/$1 [L] # rewrites requests to example.com/*

If I understand correctly, you can access your application from:

# http://example.com/cakephp/*   # normally served from html/cakephp/

... but instead you want URLs to display like this:

# http://example.com/*           # normally served from html/

The simplest option would be to move all the files and folders inside the cakephp directory up one level, as it's intended to work "out of the box", so the directory structure was like this:

# html/.htaccess               <- this file would then ...
# html/app
# html/app/.htaccess
# html/app/webroot             <- ... rewrite requests to here
# html/app/webroot/.htaccess
# html/cake

If you wish to keep the cakephp containing directory, then you will need to add your own .htaccess file to the html/ directory to tell Apache of your intentions. The structure would be like this:

# html/.htaccess               <- your .htaccess file goes here
# html/cakephp/.htaccess       <- it should look similar to this one
# html/cakephp/app
# html/cakephp/app/.htaccess
# html/cakephp/app/webroot     <- you need to rewrite requests to here
# html/cakephp/app/webroot/.htaccess
# html/cakephp/cake

The contents of which can be copied from the first CakePHP .htaccess file (as noted above) and altered slightly to produce the result you are after. Something like this:

RewriteEngine on
RewriteRule ^$   cakephp/app/webroot/   [L] # rewrites requests to example.com/
RewriteRule (.*) cakephp/app/webroot/$1 [L] # rewrites requests to example.com/*
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文