2012-04-05 38 views
12

Tôi đang cố điều chỉnh tệp htacess của mình để bỏ qua quy tắc viết lại nếu tệp hoặc thư mục tồn tại, nhưng khi tệp tồn tại, nó sẽ thay đổi URL thành một thứ khác. Tôi không biết tại sao điều này lại xảy ra. Đây là tệp htaccess của tôi:RewriteCond bỏ qua quy tắc nếu tệp hoặc thư mục tồn tại

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^project/([^/\.]+)/?$ index.php?view=project&project=$1 [L] 
RewriteRule ^for/content/ag index.php?view=opening&section=ag [L] 
RewriteRule ^for/content/bus index.php?view=opening&section=bus [L] 
RewriteRule ^for/content/fcs index.php?view=opening&section=fcs [L] 
RewriteRule ^for/content/market index.php?view=opening&section=market [L] 
RewriteRule ^for/content/trade index.php?view=opening&section=trade [L] 
RewriteRule ^for/content/teched index.php?view=opening&section=teched [L] 
RewriteRule ^for/content/([^/\.]+)/?$ index.php?view=content_area&section=$1 [L] 

Thư mục/dự án/nti tồn tại, với tệp index.php. Khi địa chỉ mywebsite.com/folder/project/nti được nhập, nó thay đổi thành mywebsite.com/folder/project/nti/?view=project & project = nti. Tôi đang áp dụng điều này trên một máy chủ thử nghiệm nơi trang web mẫu nằm trong một thư mục con, nhưng khi được triển khai, nó sẽ nằm trong thư mục máy chủ web gốc.

Cảm ơn bạn đã trợ giúp!

Trả lời

25

Remove thêm [OR] và có mã của bạn như thế này:

# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
# If the request is not for a valid link 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^project/([^/.]+)/?$ index.php?view=project&project=$1 [L,NC,QSA] 
Các vấn đề liên quan