2017-06-07 113 views
7

Ön uçta React ve arka plan olarak WordPress ile bir web sitesi hazırladım. Arama motoru tarayıcılarının sitemi görmesi için, sunucu tarafında ön ayarlamalar yaptım ve arama motorlarından gelen proxy isteklerine htaccess kurmaya çalışıyorum, böylece bunlar önceden oluşturulmuş sayfalar için sunuldu.Arama motoru tarama isteklerinin proxy'si için htaccess'i nasıl düzeltebilirim?

Test için Google Web Yöneticileri'nde "Google Gibi Getir" aracını kullanıyorum. İşte

benim girişimi:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    <IfModule mod_proxy_http.c> 
    RewriteCond %{REQUEST_FILENAME} -f [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR] 
    RewriteCond %{QUERY_STRING} _escaped_fragment_ 
    # Proxy the request ... works for inner pages only 
    RewriteRule ^(?!.*?)$ http://example.com:3000/https://example.com/$1 [P,L] 

    </IfModule> 
</IfModule> 
# BEGIN WordPress 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

Benim sorunum bu yönerge (http://example.com/inner-page/) ana sayfam için çalışmak ve sadece iç sayfalar için çalışır olmamasıdır:

RewriteRule ^(?!.*?)$ http://example.com:3000/https://example.com/$1 [P,L] 

I Bu satırı aşağıdaki satıra değiştirin, ana sayfa isteği gerçekten doğru bir şekilde proxy edildi, ancak iç sayfalar çalışmayı durdurur. Benim ana sayfası da googlebot doğru proxy böylece

RewriteRule ^(index\.php)?(.*) http://example.com:3000/https://example.com/$1 [P,L] 

beni yeniden yazma kuralını düzeltmek yardımcı olabilir mi?

cevap

1

Değişim RewriteRule için:

RewriteRule ^(.*)/?$ http://example.com:3000/https://example.com/$1 [P,L] 
+0

olacaktır. Sadece iç sayfalar taranıyor. Ana sayfa hala Google web yöneticileri aracımda "Bulunamadı" hatası gösteriyor. – Enthusiast

+0

Her zaman Google Gibi Getir aracı tarafından kullanılan takip eden eğik çizgi olabilir mi? – Enthusiast

+0

Kuralımı isteğe bağlı son eğik çizgi ile değiştiriyorum. – Croises

1

İlk

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    <IfModule mod_proxy_http.c> 
    RewriteCond %{REQUEST_FILENAME} -f [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR] 
    RewriteCond %{QUERY_STRING} _escaped_fragment_ 
    # Proxy the request ... works for inner pages only 
    RewriteRule ^(?!.*?)$ http://example.com:3000/https://example.com/$1 [P,L] 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 

    </IfModule> 
</IfModule> 

Sonra ^(?!.*?)$^.*$ veya [a-zA-Z0-9-.]* gibi iyi bir desen ile değiştirmek repetetions kaçının. Orada 0 veya daha fazla bayrağı (*) kullanmayı unutma.

doğru kod Bunu denedim, ve sınamak için Google gibi Getir aracını kullanılan

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    <IfModule mod_proxy_http.c> 
    RewriteCond %{REQUEST_FILENAME} -f [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR] 
    RewriteCond %{QUERY_STRING} _escaped_fragment_ 
    # Proxy the request ... works for inner pages only 
    RewriteRule ^(.*)$ http://example.com:3000/https://example.com/$1 [P,L] 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 

    </IfModule> 
</IfModule>