【问题标题】:htaccess subdirectory URLS to roothtaccess 子目录 URLS 到根目录
【发布时间】:2013-03-04 19:44:16
【问题描述】:

我想将子目录中的所有文件重定向到它们的新根 URL。

旧网址是

www.domain.com/subdirectory/filename-here.html

新位置是

www.domain.com/filename.here.html

旧网址已在 Google 中列出,需要对这些网址进行某种重定向。 我确定 htaccess 是去这里的方式,但不确定解决方案。

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:
    RewriteEngine on
    RewriteRule %{REQUEST_URI} ^/subdirectory/.*
    RewriteRule subdirectory/(.*)$ /$1 [R=301,L]
    

    here 上测试。如果它不起作用 - 以这种方式为[^/] 添加屏蔽:[^\/]

    【讨论】:

    • 几乎完美...子目录中的链接也被重定向到根目录。例如。 www.domain.com/subdirectory/subdirectory2/filename.html 应该是 www.domain.com/subdirectory2/file.html 可以吗?
    • 您只想删除一个子目录?
    • 是的,我想要 :)
    猜你喜欢
    • 2012-01-26
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    相关资源
    最近更新 更多