[英].htaccess in subfolder
主站點使用.htaccess運行WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我將在子目錄site.com/online/
創建一個CodeIgniter應用程序。如果只是在子文件夾中添加CI .hta文件,它將無法正常工作。 CI .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js)
RewriteRule ^(.*)$ /index.php?/$1 [L]
是否可以組合兩個.htaccess文件或在CI子文件夾中使用.htaccess執行某些操作? 謝謝。
UPD。 感謝您的回答,我嘗試了所有變種,並最終將項目移至子域。
首先,你的.htaccess應該是這樣的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} !^GET\s/+online/ [NC]
RewriteRule . /index.php [L]
</IfModule>
#Then add this for CI handling in the same .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !index\.php [NC]
RewriteRule ^online/(.*)$ online/index.php?/$1 [L,NC]
然后,您可以在online
子文件夾中刪除(或重命名).htaccess。
嘗試使用codeigniter .htaccess:
RewriteEngine on
RewriteBase /online
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js)
RewriteRule ^(.*)$ /index.php?/$1 [L]
否則,對該子文件夾的所有請求都將被重定向到wordpress。
你在設置AllowOverride嗎? 根據文檔,您需要允許FileInfo
覆蓋mod_rewrite。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.