【问题标题】:.htaccess mod_rewrite redirect all css to page/controller.htaccess mod_rewrite 将所有 css 重定向到页面/控制器
【发布时间】:2016-03-06 12:55:43
【问题描述】:

如何使用 .htaccess 将任何 .css 文件重定向到我服务器上的页面/控制器?

我目前有以下规则:

# Remove index.php from Codeigniter
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

我现在希望将任何 .css 文件重定向到例如 http://127.0.0.1/asset/css?file=stylesheet.css。我尝试了以下但收到 404。

RewriteRule .*\.(css)$ /asset/css?file=$0 [NC,L]

【问题讨论】:

    标签: css apache .htaccess codeigniter mod-rewrite


    【解决方案1】:
    #Rule for css
    RewriteRule ([^.]+)\.css$ asset/css?file=$1.css [NC,L]
    #end of css rule
    # Remove index.php from Codeigniter
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 2010-12-29
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      • 1970-01-01
      相关资源
      最近更新 更多