2012-08-17 32 views
0

當我進入http://www.example.com/index.php到blowser
我可以使用重寫規則重定向到http://www.example.com/web/index.php

OK,現在如果我進入http://www.example.com/test.php
但「test.php的」文件不網頁/文件夾中存在
實際上,這個文件存在於/ admin文件夾
那麼,我可以重定向到http://www.example.com/admin/test.php

使用http://www.example.com/xxx.php重定向到不同的URL?
以下是我的.htaccess,但它不能正常工作...
我可以使用mod_rewrite重定向到不同的URL嗎?

RewriteEngine敘述在

重寫規則^(。*)$網/ $ 1 [NC]

重寫規則^(。*) $管理員/ $ 1 [NC]

回答

0

嘗試使用這樣的:

RewriteEngine On 

# checks if requested file exists in /web/ 
RewriteCond %{DOCUMENT_ROOT}/web%{REQUEST_URI} -f 
RewriteRule ^(.*)$ /web/$1 [L] 

# checks if requested file exists in /admin/ 
RewriteCond %{DOCUMENT_ROOT}/admin%{REQUEST_URI} -f 
RewriteRule ^(.*)$ /admin/$1 [L] 
相關問題