简体   繁体   English

.htaccess在根目录和公共目录中的帮助

[英].htaccess help within root and public

I have a small mvc application where I'm trying to force the url to go from www.example.com to www.example.com/public. 我有一个小型的mvc应用程序,试图将网址从www.example.com转到www.example.com/public。

In order to do this, I have a .htaccess file in the root (/) and then another .htaccess within the /public folder to point to index.php with friendly urls. 为了做到这一点,我在根目录(/)中有一个.htaccess文件,然后在/ public文件夹中有另一个.htaccess文件,以指向带有友好URL的index.php。 I believe the issue is within the htaccess file that sits in the public folder, I need all requests to go through index.php 我相信问题出在公共文件夹中的htaccess文件中,我需要所有请求才能通过index.php

I have tried a few threads on stackoverflow but seems to give me a server 500 error when I access www.example.com 我在stackoverflow上尝试了一些线程,但是当我访问www.example.com时,似乎给了我一个服务器500错误

.htaccess of root 根的.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /public/

</IfModule>

.htaccess of public folder 公用文件夹的.htaccess

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME}% !-f
    RewriteCond %{REQUEST_FILENAME}% !-d
    #allow images, css and js links
    RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC]


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

</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule (.*) /public/index.php

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

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