2017-04-11 169 views
1

我有一個子目錄接觸和內部contact.php和contact_content.php和.htaccess文件htaccess的重寫文件路徑的文件夾路徑

在htaccess文件我已經以下代碼:

Options +FollowSymLinks 
RewriteEngine on 

RewriteCond %{REQUEST_URI} ^/contact/contact.php 
RewriteRule^/contact [R=301,L] 

RewriteRule ^/$ contact.php [NC,L,END] 

# deny access 
RewriteRule ^(contact_content)\.php - [F,L,NC] 

拒絕接入部分和第一重寫規則的工作完美,但 問題是第二rewriterule->當我去localhost/contact我顯示在聯繫人目錄的文件列表,而不是contact.php網站

+0

希望我目前的職位將正常工作。我在所有你闖民宅 –

+0

部分做的情況下已經測試過,我會放代碼現在適用於我 – MPavic

回答

1

這適用於我 - >改性薩赫勒古拉蒂回答

Options +FollowSymLinks -Indexes 
RewriteEngine On 

RewriteCond %{REQUEST_URI} ^/contact/contact.php 
RewriteRule^/contact [R=301,L] 

RewriteCond %{REQUEST_URI} ^/contact/?$ 
RewriteRule ^(.*)$ /contact/contact.php [L,QSA,END] 

RewriteRule ^(contact_content)\.php - [F,L,NC] 
1

Hopef ully它會正常工作。

RewriteEngine On 

Options -Indexes 
RewriteCond %{REQUEST_URI} contact\.php$ 
RewriteRule ^(.*)$ /contact [R=301] 


RewriteCond %{REQUEST_URI} ^/contact/?$ 
RewriteRule ^(.*)$ /$1/contact.php [L,QSA,END] 

RewriteRule ^(contact_content)\.php - [F,L,NC] 
+0

不起作用,我現在得到403錯誤 – MPavic

+0

所以你想在這種情況下,當用戶鍵入'/ contact' –

+0

所以當用戶類型/聯繫我想顯示contact.php頁 – MPavic