用于XYZ脚本的Nginx配置

时间:2018-06-11 14:35:12

标签: nginx url-rewriting mod-negotiation

我一直在寻找和测试这个脚本的许多版本。有人能够将其转换为有效的NGINX脚本吗?

    <IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine on
Options +FollowSymlinks

IndexIgnore *
RewriteRule \.htaccess - [F]

RewriteBase /

RewriteRule (.*)(common|library|upload|userfiles)(\/)(.*)$ $2$3$4 [QSA,L]

RewriteCond %{request_uri} ^(.*)(addons|themes)(\/)(.*)$
    RewriteRule (.*)(addons|themes)(\/)(.*)(css|fonts|js|images)(\/)(.*)$ %2/$4$5$6$7 [L]

RewriteCond %{request_uri} ^(.*)(admin|cron|display|installation)(\/)(.*)$
    RewriteRule (.*)(css|fonts|js|images)(\/)(.*)$ %2/$2$3$4 [L]

RewriteRule (.*)(css|fonts|js|images)(\/)(.*)$ $2$3$4 [L]

RewriteRule ^(.*)(index\.php)(\/?)(.*)$ $1index.php?page=index/$4 [QSA,L]

#below rewrite handles admin urls from addons also
RewriteCond %{request_uri} !^index\.php
    RewriteCond %{request_uri} ^(.*)(admin\/)(.*)$
        RewriteRule (.*)(admin\/)(.*)$ $1$2index.php?page=$3 [QSA,L]

#below rewrite handles addons direct access urls
RewriteCond %{request_uri} !^index\.php
    RewriteCond %{request_uri} ^(.*)(addons\/)(.*)$
        RewriteRule (.*)(addons\/)(.+?\/)(.*)$ $2$3index.php?page=$4 [QSA,L]

RewriteCond %{request_uri} !^index\.php
    RewriteCond %{request_uri} ^(.*)(cron|display|installation)(\/)(.*)$
        RewriteRule (.*)(cron|display|installation)(\/)(.*)$ $2$3index.php?page=$4 [QSA,L]

RewriteCond %{request_uri} !^index\.php
    RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

我知道如何进行简单的重写但无法使$2$3$4起作用。也许它在mod_negotiation部分?

0 个答案:

没有答案