开发者

Cakephp htaccess mod_rewrite on GoDaddy [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 6 years ago.

Improve this question

I have a godaddy hosting account and having some开发者_Python百科 problems with routing. The files are under /cakephp under the default /html folder. The full url is still showing instead of the desired

 www[dot]domain[dot]org

Please help.

The current setup

/cakephp/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cakephp
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

/cakephp/app/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cakephp
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>

/cakephp/app/webroot/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cakephp/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule> 


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/*
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜