我在子文件夹中有网站内容 (mydomain/subfolder/index.php),现在我将所有内容复制到根文件夹(mydomain/index.php).
I had website content in a subfolder (mydomain/subfolder/index.php), now I copied everything over to the root folder (mydomain/index.php).
我想使用 .htaccess 将所有为旧页面添加书签的访问者重定向到新内容(至少到新的 index.php).
I would like to redirect all the visitors that have bookmarked the old page to the new content (at least to the new index.php) using .htaccess.
这是否正确:
RewriteEngine on RewriteRule /subfolder/^(.*)$ mydomain [R=301,L]?
我应该将 .htaccess 文件放在子文件夹还是根文件夹中?
And where would I place the .htaccess file, in the subfolder or the root folder?
推荐答案将以下 .htaccess 放在 /(你的 index.php 所在的位置)应该做技巧:
Placing the following .htaccess in / (where your index.php is located) should do the trick:
RewriteEngine on RewriteRule ^subfolder/(.*)$ /$1 [R=301,L]或者您可以将以下 .htaccess 放在 /subfolder 中:
Or you could place the following .htaccess in /subfolder:
RewriteEngine On RewriteRule ^(.*)$ /$1 [R=301,L]注意 .* 周围的 () 和 $1 将 /subfolder/someFile.php 重定向到/someFile.php.如果跳过它,/subfolder 中的所有内容都会重定向到 /.
Note that the () around .* and the $1 redirects /subfolder/someFile.php to /someFile.php. If you skip it, everything in /subfolder redirects to /.
更多推荐
.htaccess 从子文件夹重定向到域名
发布评论