我在两个独立的子目录中运行了两个CodeIgniter v2.1.4项目,即 dev 和 prod 。以下是文件结构:
/ (root)
.htaccess (01)
- dev
- .htaccess (02)
- application
- system
- assets
- js
- css
- img
- prod
- .htaccess (03)
- applications
- system
- assets
- js
- css
- img
我想做的是
以下是 .htaccess(01)
RewriteEngine On
RewriteBase /prod
RewriteRule ^(.*)$ /prod/index.php?/$1 [L]
.htaccess(02)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|robots\.txt|changelog\.html)
RewriteRule ^(.*)$ /dev/index.php?/$1 [L]
.htaccess(03)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|robots\.txt|changelog\.html)
RewriteRule ^prod/(.*)$ /prod/index.php?/$1 [L]
问题:现在不起作用的是资产文件夹中的文件必须在要加载的网址中包含 dev 或 prod ,例如
答案 0 :(得分:0)
下面应该是你的.htaccess(01)
RewriteEngine On
RewriteRule ^(assets/.*)$ /prod/$1 [L,NC]
RewriteRule !^prod/ /prod/index.php?%{REQUEST_URI} [L,NC]
您可以按原样保留其余代码。