2015-09-30 76 views
1

我知道這個問題已被問過很多次,但我需要幫助。我已經花了幾個小時,我不知道在以下htaccess代碼中出現了什麼問題。htaccess問題 - 不重寫url

Options +FollowSymLinks 

RewriteEngine on 

RewriteRule services/z/(.*)/ services.php?z=$1 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://rcunlocks.com/$1 [R,L] 

我試圖重新寫入網址

https://rcunlocks.com/services.php?z=spus3

https://rcunlocks.com/services/spus3

如果有什麼不對我的htaccess的文件,請告訴我。

您的幫助真的很感謝。謝謝。

+0

我猜你必須添加'[NC,L]'您的規則後,因爲最後一條規則將改寫一切恢復到默認結構。 – GuyT

回答

0

試試這個

Options +FollowSymlinks 
RewriteEngine on 
# check that the request url is neither a file nor a directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^services/(.*) services.php?z=$1 [NC] 
+0

它沒有工作。謝謝 – rob

0

我看到2個問題:

  1. 重定向規則重寫後可能會暴露你的內部URI /services.php?z=spus3到瀏覽器
  2. 選項MultiViews可以覆蓋此重寫規則。

要解決這兩個問題都這樣說:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=302,L] 

RewriteRule ^services/z/([^/]+)/?$ services.php?z=$1 [L,QSA,NC] 
+0

我試過了,仍然沒有運氣。我以爲L會阻止它移動到下一個重寫規則..我是否正確? – rob

+0

在瀏覽器中輸入「https:// rcunlocks.com/services/spus3」URL時會出現什麼錯誤? – anubhava

+0

我有一個多選擇頁面 - 狀態300 – rob