2015-02-05 16 views
0

嗨一直在尋找年齡,並嘗試了幾個例子,但沒有任何工作。我希望我的URL看起來好像它位於根目錄,而不是買子目錄:HTAccess重寫的網址看起來像根

http://www.example.com/buy/*.html 

http://www.example.com/*.html 

RewriteRule ^buy/(.*)$ $1 [L] 

不斷收到頁面無法正常重定向。 @巴拿馬傑克

任何想法謝謝。

的.htaccess

# non-www to www 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com$ 
RewriteRule (.*) http://www.example.com/$1 [R=301,L] 


AddType application/x-httpd-php .html .htm 


# rewrite products to root located  
RewriteRule ^buy/(.*)$ $1 [L] 


# Remove index.php or index.htm/html from URL requests 
RewriteEngine On 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(php|html?)\ HTTP/ 
RewriteRule ^([^/]+/)*index\.(html?|php)$ http://www.example.com/$1 [R=301,L] 


# GZIP 
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/x-javascript application/javascript 


# Redirect all index calls 
RewriteEngine On 
RewriteRule ^index\.(php|html?)$ http://www.example.com/ [R=301,L] 


#Custom 404 errors 
ErrorDocument 404 /productslinks404.html 
+0

@Panama更新我的問題。感謝您的時間。 – Barton 2015-02-13 10:47:38

回答

0

如果/buy/somepage.html是一個真正的頁面,然後嘗試您的規則這樣,如果你想

http://www.example.com/page.html

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*).html$ /buy/$1.html [L] 
+0

謝謝你的回覆。我爲商店本身另外重寫了一個動態網址,現在當我輸入www.example,com/new.html,即www.example.com/buy/buy/buy/buy/buy/時,網頁無法正確重定向買/買/買/買/買/買/買/買/買/買/買/買/買/買/買/ new.html – Barton 2015-02-06 07:41:17

+0

你所有的規則是什麼?編輯你的問題,並添加你的htaccess文件的內容,而不僅僅是它的一部分。 – 2015-02-06 15:10:03