2013-02-14 21 views
0

我試着去使用.htaccess文件Apache服務器上,以點/ cmsfiles /動畫書/ thisFlipBook /到/ thisFlipBook的.htaccess重寫卸載文件夾資源

我用盡:

RewriteRule ^/thisFlipBook/ /cmsfiles/flipbooks/thisFlipBook[L,R=302] 

以及爲:

RewriteRule ^/thisFlipBook/cmsfiles/flipbooks/thisFlipBook[L] 

(而不將R標記,以便mod_rewrite的知道它的內部apache的重定向代替具有瀏覽器發送對重寫資源的新請求的)

第一條規則出現了404,並在第二個結果:

/thisFlipBook/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/ 

但是,如果您手動導航/ cmsfiles /動畫書/ thisFlipBook它設法找到index.html文件,併成功地加載它。

我做錯了什麼?

另請參見:服務器端的Apache重定向和卸載的文件夾是正確的方式做這件事嗎?客戶開始請求這麼多的flipbooks,爲了部署,我們將它們從項目中移出。

+0

如果您不解釋詳細信息,沒有人可以對這個奇怪的「未安裝文件夾」問題說些什麼。 – arkascha 2013-02-14 07:47:42

+0

無窮無盡的重寫循環與index.php路徑似乎是一些副作用與cms也正在重寫傳入的請求。 cms最有可能將'flipbooks/'重定向到名爲index.php的內部路由器。然後再次重寫你的重寫規則並重新寫入......無盡的循環。 – arkascha 2013-02-14 07:49:24

+0

噢,並且...在路徑和方括號內的標誌之間需要一些空格。在上面給出的示例規則中,不存在這樣的空白。我很驚訝你不會收到錯誤... – arkascha 2013-02-14 07:50:35

回答

0

也許這就是你需要:

Options +FollowSymlinks 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^thisFlipBook/? cmsfiles/flipbooks/thisFlipBook [R=301,L,NC] 

永久

http://example.com/thisFlipBook

重定向到:

http://example.com/cmsfiles/flipbooks/thisFlipBook

假定所有的字符串是固定的。

然而,如果thisFlipBook不是一個固定的串,與這一個替換的重寫規則:

RewriteRule ^([^/]+)/? cmsfiles/flipbooks/$1 [R=301,L,NC] 

對於內部映射,從[R=301,L,NC]除去R=301