Why is my .htaccess file redirecting to full server path instead of relative path?

前端 未结 3 1139
别跟我提以往
别跟我提以往 2021-01-19 12:18

I\'ve never had a problem with cakePHP before, but something\'s odd about this server and is causing the redirects in the .htaccess files to behave oddly.

CakePHP us

相关标签:
3条回答
  • 2021-01-19 12:52

    The solution to your question can be found towards the bottom of this page in the cakephp book:

    For many hosting services (GoDaddy, 1and1), your web server is actually being served from a user directory that already uses mod_rewrite. If you are installing CakePHP into a user directory (http://example.com/~username/cakephp/), or any other URL structure that already utilizes mod_rewrite, you'll need to add RewriteBase statements to the .htaccess files CakePHP uses (/.htaccess, /app/.htaccess, /app/webroot/.htaccess).

    I've deployed CakePHP from my profile's public_html folder as well. I had to change 3 the same .htaccess files mentioned above. Just add RewriteBase /~username/ to the .htaccess files just after RewriteEngine on!

    0 讨论(0)
  • 2021-01-19 13:01

    It was quite simple (using uolhost shared host):

    Edit both .htaccess files:

    /webroot/.htaccess

    /.htaccess

    Add the following line: RewriteBase /

    Here is the whole /webroot/.htaccess file:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    0 讨论(0)
  • 2021-01-19 13:09

    Try removing .htaccess from main file... It worked for me

    0 讨论(0)
提交回复
热议问题