【问题标题】:Apache rewrite: if not exists in /public open as /public/index.php/Apache 重写:如果 /public 中不存在,则打开为 /public/index.php/
【发布时间】:2013-03-08 02:59:12
【问题描述】:

我想要

  1. http://kemtime2_neu.pr.domain.de/css/style.css 打开为 http://kemtime2_neu.pr.domain.de/public/css/style.css
  2. http://kemtime2_neu.pr.domain.de/login 打开为 http://kemtime2_neu.pr.domain.de/public/index.php/login

我有

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/index.php/$1 [L]

这适用于 2。

如何使它适用于 1.?请注意,我无法更改文档根目录(对不起!)。

【问题讨论】:

    标签: apache mod-rewrite


    【解决方案1】:

    找到了:

    # Redirect to static content
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond /var/www/de/domain/pr/kemtime2_neu/public%{REQUEST_URI} -f
    RewriteRule ^(.+)$ /public/$1 [L]
    
    # otherwise redirect to script
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /public/index.php/$1 [L]
    

    【讨论】:

      【解决方案2】:

      将您的DocumentRoot 更改为指向public 目录?

      【讨论】:

        猜你喜欢
        • 2013-03-08
        • 1970-01-01
        • 2018-10-12
        • 2019-12-27
        • 1970-01-01
        • 2021-06-10
        • 1970-01-01
        • 1970-01-01
        • 2014-09-07
        相关资源
        最近更新 更多