我有一个从子目录运行的站点 - 托管在HostGator上。大多数htaccess规则都可以重定向到子目录,除了一个。
如果我去example.com/products - 我得到一个不可见的重定向到example.com/subfolder/products - 它在地址栏中正确显示为example.com/products
但是,如果我去example.com/news - 我得到一个可见的重定向到example.com/subfolder/news - 它在地址栏中显示不正确,例如example.com/subfolder/news
以下是我在根文件夹中使用的.htaccess代码:
RewriteEngine on
RewriteRule ^$ /subfolder/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1 [L]
供参考:如果我在浏览器中输入example.com/news,我可以直接重定向到example.com/subfolder/news - 但是,如果我第二次在浏览器中输入example.com/news,我将被无形重定向!
Google已抓取该网站并提供可见的重定向网址(因此它们在Google中显示为example.com/subfolder/news)
更新:
在.htaccess
个文件中我唯一拥有的其他行Options -Indexes
在子文件夹 .htaccess
文件中,我也有
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L,QSA]
ErrorDocument 403 http://www.example.com/403
ErrorDocument 404 http://www.example.com/404
ErrorDocument 500 http://www.example.com/500
我和HostGator在一起会有什么影响吗?