dongyue5686 2017-02-22 17:44
浏览 37
已采纳

.htaccess奇怪的重定向PHP MVC

For anyone interested this was solved very simply by putting the root of my site to the public folder, Rookie error.

Hello ive just finished setting a website, and i am getting a weird redirect issue. When i first type in the URL https://project-wheels.co.uk when it gets to the site it redirects to https://project-wheels.co.uk/public. This still works fine as this is where the project index is.

My directory is as follows Application [folder] public [folder] .htaccess

Inside this first .ht access is

RewriteEngine on
RewriteRule ^(.*) public/$1 [L]

Then inside the public folder i have another htaccess

Options -MultiViews

RewriteEngine On

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The index file in the public folder starts the mvc application etc.

I used the mini-master template and i have no experience at all with htaccess files other than these.

To give a little more information this website is actually hosted as a Addon domain and is routed to a folder in the public_html folder of the root, Im not sure if this makes any difference.

Thank you in advance Ryan

  • 写回答

1条回答 默认 最新

  • dpo15099 2017-02-22 18:05
    关注

    try this on your first .htaccess

    RewriteEngine on 
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?