1
我想知道如何以Google友好的方式將/news
重定向到/news/
,因爲Google將它們視爲2個不同的頁面。 我已經在使用meta規範url,但是如何使用RewriteRule做到這一點?重定向從/新聞到/新聞/
RewriteRule ^news$ /news.php [NC]
RewriteRule ^news/$ /news.php [NC]
我想知道如何以Google友好的方式將/news
重定向到/news/
,因爲Google將它們視爲2個不同的頁面。 我已經在使用meta規範url,但是如何使用RewriteRule做到這一點?重定向從/新聞到/新聞/
RewriteRule ^news$ /news.php [NC]
RewriteRule ^news/$ /news.php [NC]
試着讀這個link我相信它描述和解決你的問題。
這表明添加爲.htaccess
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
在你的情況,如果你只想要一個簡單的規則
RewriteRule ^news$ ^news/$ [NC]
RewriteRule ^news/$ /news.php [NC]
謝謝你,就像一個魅力 – slownage 2012-04-07 10:27:06