2012-02-21 62 views
4

如何我能得到阿帕奇追加路徑目錄URL中使用的htaccess

http://localhost/index.php 
http://localhost/create/index.php 
http://localhost/create/contact.php 
http://localhost/engage/page1/services.php 

重定向到

http://localhost/Project1/index.php 
http://localhost/Project1/create/index.php 
http://localhost/Project1/create/contact.php 
http://localhost/Project1/engage/page1/services.php 

分別?

基本上我需要「PROJECT1」(或任何其他字符串我認爲合適)追加到URL路徑的開始

感謝

回答

2

可以使用負前瞻是這樣的:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# redirect to /Project1/ if it is not already /Project1/ 
RewriteRule ^((?!Project1/).*)$ Project1//$1 [L,NC]