2014-06-24 126 views
1

我的文件結構中有一個名爲「finder」的目錄,我想重寫一個以finder爲基名的url。例如採取www.mysite.com/finder.htaccess重寫其中url基名稱與目錄名稱相同

這裏是重寫規則我想:

RewriteRule ^finder/?$ /finder/directory/listings.php [NC,L] 

而是一個重寫我得到一個404頁面未找到的消息成功的。對於什麼是值得我有一個正在這個網址www.mysite.com/finder/california這個規則重寫規則...

RewriteRule ^finder/([a-zA-Z0-9+\-]*)/?$ /finder/directory/listings.php?s=$1 [NC,L] 

..和它的工作。

我試過DirectorySlash Off我的.htaccess但這也不工作。任何關於我失蹤的線索?謝謝。

回答

1

我看到兩個潛在的麻煩地區:

  1. 這一規則的htaccess文件不能在finder文件夾中。確保它位於DOCUMENT_ROOT目錄中。
  2. 重寫中可能存在正斜槓的問題。

測試基於Apache 2.2和2.4:在瀏覽器

  • RewriteRule ^finder/?$ directory/listings.php [NC,L]
  • 網址:http://www.example.com/finder
  • 重定向到:http://www.example.com/directory/listings.php

讓我知道這是否正常工作。

+0

嗯,是的,我把重寫改爲DOCUMENT_ROOT,正如你所建議的那樣,它工作。謝謝您的幫助。 – ctown4life

+0

非常歡迎,下次再見。 :) – zx81

相關問題