簡體   English   中英

Apache&mod_rewrite-找不到索引

[英]Apache & mod_rewrite - index not found

這可以按需工作,除了index或“索引目錄”中的任何內容(例如index/foo將失敗。

RewriteEngine on

# base dir
RewriteBase /project/

# allow assets/ directory
RewriteRule ^(assets)/(.*)$ $0 [L]

# direct all else to index.php
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1?%{QUERY_STRING} [L]

我已經嘗試過了,但是仍然無法解決:

RewriteRule ^index(/.*)?$ index.php/$1?%{QUERY_STRING} [L]

試試這個代碼:

Options -MultiViews
RewriteEngine on
# base dir
RewriteBase /project/

# allow assets/ directory
RewriteRule ^(assets)/(.*)$ $0 [L]

# direct all else to index.php
RewriteRule ^((?!index\.php$).*)$ index.php/$1 [L,NC]

Apache's content negotiation module使用Option MultiViews ,該Apache's content negotiation module mod_rewrite 之前運行,並使Apache服務器匹配文件擴展名。 因此/file可以位於URL中,但它將提供/file.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM