我在子文件夹中有网站内容( 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).
我想使用重定向所有将旧页面添加为书签的访问者,使其指向新内容(至少指向新index.php)。 htaccess。
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 放入 / (其中的索引.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 放在 /子文件夹:
Or you could place the following .htaccess in /subfolder:
RewriteEngine On RewriteRule ^(.*)$ /$1 [R=301,L]请注意,() 。* 和 $ 1 重定向 /subfolder/someFile.php 到 /someFile.php 。如果您跳过它,则 /子文件夹中的所有内容都会重定向到 / 。
Note that the () around .* and the $1 redirects /subfolder/someFile.php to /someFile.php. If you skip it, everything in /subfolder redirects to /.
更多推荐
.htaccess从子文件夹重定向到域名
发布评论