2013-08-05 67 views
0

我怎麼能做到這一點htaccess的htaccess的重定向所有鏈接纔可但具體的人

/main_dir/([a-z-]+)/dir1 - this should remain as it is 
/main_dir/([a-z-]+)/dir2 - this should remain as it is 
/main_dir/([a-z-]+)/dir2/UQ13A -this should remain as it is 

/main_dir/([a-z-]+)/UQ13A -should take me to /main_dir/$1/dir2/UQ13A 

UQ13A - 可以是包含[A-ZA-任何字符串Z0-9-]

我不太熟悉負面看法,看起來後面

現在我有這樣的事情

/main_dir/([a-z-]+)/(?!(dir1|dir2)) /main_dir/$1/dir2/$2 

這是不工作

回答

0

啓用mod_rewrite的,並通過httpd.conf的.htaccess,然後把這個代碼在你.htaccessDOCUMENT_ROOT目錄:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

RewriteRule ^main_dir/([a-z-]+)/(?!(?:dir1|dir2)/)(.+)$ /main_dir/$1/dir2/$2 [L,NC]