RewriteEngine On
RewriteRule ^/showlisting/(.*)$ showlisting.php/$1 [L]
RewriteRule ^/listings/(.*)$ listings.php/$1 [L]
RewriteCond %{HTTP_HOST} ^mydomain\.
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
ErrorDocument 404 /notfound
在上面的工作,這就是我想要達到的目標:條件刪除.PHP並不如預期
- 我要轉發的任何URL如www.mydomain.com/ showlisting/my-listing-data/with-more-slashes/and-some-text來顯示www.mydomain.com/showlisting*內容.php */my-listing-data/with-more-slashes /和一些文本,但URL掩碼,以便.php不會出現在瀏覽器窗口。
- 我也想追加www當www不存在於搜索引擎優化目的的請求,雖然我不知道這是多麼重要這些天。
當我訪問www.mydomain.com/showlisting/my-listing-data/with-more-slashes/and-some-text但是它顯示了一個404錯誤,但要以.php加入showlisting,它工作正常。有任何想法嗎?
但是請注意www的附加。工作正常 - 這不是我正在努力的部分,儘管我將這部分代碼包括在內以進行全面分析。
在哪個目錄中的.htaccess文件在什麼位置? – Dion 2012-04-10 19:51:37
確保斜槓同步。它可以是規則正則表達式的w/o,也可以是替換規則。 – hakre 2012-04-10 19:53:01
一切都在public_html文件夾下。所有.php文件,.htaccess等 – jeffkee 2012-04-10 19:57:20