2016-08-09 119 views
1

我有一個問題,我沒有找到解決方案。htacess重定向到子文件夾導致太多http狀態301重定向

我喜歡我的web根目錄中的一個子文件夾我想將所有URL重定向到這個子文件夾而不更改URL。

例如:domain.com/article123.html - > redirecting-> domain.com/subfolder/article123.html但在地址欄保持domain.com/artcle123.com

所以我把跟隨我的根htaccess的:

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] 
RewriteRule !^subfolder/ /subfolder%{REQUEST_URI} [L,NC] 

但現在當我測試的URL與http://httpstatus.io我得到以下

301 → Error while fetching URL. 11 redirect 

在子文件夾中我還有一個htaccess的:

RewriteCond %{REQUEST_METHOD} =GET 
RewriteCond %{QUERY_STRING} ^$ 
RewriteCond %{REQUEST_URI} "(.*)index.php" 
RewriteRule ^index\.php$ %1 [R=301,L] 


RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} ^(.*)\.(php|css|js|gif|jpg|jpeg|png)$ [NC] 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_URI} (.*)?/admin/(.*) 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_URI} (.*)?/images/(.*) 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_URI} (.*)?/templates/(.*) 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^(.+) - [L] 

RewriteCond %{REQUEST_FILENAME} -l 
RewriteRule ^(.+) - [L] 

##boosted CONTENT 
RewriteRule (^[a-z]{2})/(.*/)?info/([A-Za-z0-9_-]+)\.html.* shop_content.php?language=$1&gm_boosted_content=$3&%{QUERY_STRING} [PT,L] 
RewriteRule (.*/)?info/([A-Za-z0-9_-]+)\.html.* shop_content.php?gm_boosted_content=$2&%{QUERY_STRING} [PT,L] 

##boosted PRODUCTS 
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)\.html product_info.php?language=$1&gm_boosted_product=$3&%{QUERY_STRING} [PT,L] 
RewriteRule (.*/)?([A-Za-z0-9_-]+)\.html product_info.php?gm_boosted_product=$2&%{QUERY_STRING} [PT,L] 

##boosted CATEGORIES 
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)/?.* index.php?language=$1&gm_boosted_category=$3&%{QUERY_STRING} [L] 
RewriteRule (.*/)?([A-Za-z0-9_-]+)/?.* index.php?gm_boosted_category=$2&%{QUERY_STRING} [L] 

我不知道爲什麼。誰能幫忙?

+0

的URL是legal-dreams.biz並重定向到GX子......在這個子文件夾中我有另一個htaccess的重寫對產品的URL ,類別等 –

+0

th根URL不會引起任何問題,但每篇文章-URI例如 –

回答

0

根的.htaccess看起來不錯,試試這個在subfolder/.htaccess

RewriteEngine On 

RewriteCond %{REQUEST_METHOD} =GET 
RewriteCond %{THE_REQUEST} /index\.php 
RewriteCond %{REQUEST_URI} (.*)index\.php 
RewriteRule ^index\.php$ %1 [R=301,L,NE] 

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteRule^http://%1%{REQUEST_URI} [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} ^(.*)\.(php|css|js|gif|jpg|jpeg|png)$ [NC,OR] 
RewriteCond %{REQUEST_URI} /(admin|images|templates)/ 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

##boosted CONTENT 
RewriteRule (^[a-z]{2})/(.*/)?info/([\w-]+)\.html shop_content.php?language=$1&gm_boosted_content=$3 [QSA,L,NC] 

RewriteRule (.*/)?info/([\w-]+)\.html shop_content.php?gm_boosted_content=$2 [QSA,L,NC] 

##boosted PRODUCTS 
RewriteRule (^[a-z]{2})/(.*/)?([\w-]+)\.html product_info.php?language=$1&gm_boosted_product=$3 [QSA,L,NC] 

RewriteRule (.*/)?([\w-]+)\.html product_info.php?gm_boosted_product=$2 [QSA,NC,L] 

##boosted CATEGORIES 
RewriteRule (^[a-z]{2})/(.*/)?([A-Za-z0-9_-]+)/? index.php?language=$1&gm_boosted_category=$3 [L,QSA,NC] 

RewriteRule (.*/)?([\w-]+)/? index.php?gm_boosted_category=$2 [L,QSA,NC] 
+0

謝謝你的回答!嗯,不幸的是它的結果是一樣的......我用這個網址試了一下:http://legal-dreams.biz/de/Raeuchermischung-Kush-2-5g.html用httpstatus.io,但結果是一樣的:-( –

+0

Subdirectorys Name is「GX3」 –

+0

即使當我打開這個URL:http:// legal-dreams.biz/Raeuchermischung-Kush-2-5g.html時,它也有301重定向到http://legal-dreams.biz/de/Raeuchermischung-Kush-2-5g.html'。在我的回答中沒有規則是在前面添加'de /',我懷疑這是發生在你的代碼裏面 – anubhava