通过 .htaccess 重定向更改的站点位置的正确方法

发布于 2024-09-16 18:20:44 字数 150 浏览 3 评论 0原文

我曾经将我的网站托管在 www.mysite.com/here 现在网址只是 www.mysite.com

那么我如何正确重定向来自 www.mysite.com/here/about 的所有旧链接 访问 www.mysite.com/about

谢谢。

i used to host my site at www.mysite.com/here
now the url is simply www.mysite.com

so how do i properly redirect all old links from say www.mysite.com/here/about
to www.mysite.com/about

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年不长 2024-09-23 18:20:44

添加

RewriteRule ^mysite.com/here(.*)$ http://mysite.com/$1 [R=301,NC,L]

到您的 .htaccess 中,以便重写规则看起来类似于

RewriteRule ^mysite.com/here(.*)$ http://mysite.com/$1 [R=301,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

如果您的 Drupal 实例(例如页面)中碰巧有另一个 /here 路径,那么它会更复杂,我可能会更改该路径。

Add

RewriteRule ^mysite.com/here(.*)$ http://mysite.com/$1 [R=301,NC,L]

to your .htaccess so that the rewrite rules look something along the lines of

RewriteRule ^mysite.com/here(.*)$ http://mysite.com/$1 [R=301,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

if you happen to have another /here path in you Drupal instance (e.g. a page), then it is more complicated and I would probably change that path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文