将所有内容重写为子文件夹中的index.php

时间:2014-08-10 13:41:00

标签: php .htaccess mod-rewrite

我的命令指向

public_html

我的index.php在

public_html/webroot/

我的.htaccess在public_html /

  RewriteEngine on 
  RewriteRule ^$ /webroot/ [L]

很好地重定向到index.php

现在,我想重定向

domain.com/one/two/three

domain.com/app/webroot/index.php?1=one&2=two$three=3

我尝试了几种组合但无济于事。

2 个答案:

答案 0 :(得分:0)

你可以试试像

这样的东西
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^1/?([^/.]+)/2/([^/.]+)/3/([^/.]+)$ index.php?1=$1&2=$2&3=$3 [L]
</IfModule> 

我上面显示的示例是在apache conf文件中。我不确定.htaccess,但你可以把它翻译成.htaccess

由于

答案 1 :(得分:0)

您可以在root .htaccess中使用此代码:

RewriteEngine on

RewriteRule ^$ webroot/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+)(?:/([^/]+))?)?/?$ webroot/index.php?1=$1&2=$2&3=$3 [L,QSA]