【问题标题】:Redirecting Dynamic Url to Static Url将动态 URL 重定向到静态 URL
【发布时间】:2014-07-01 01:18:25
【问题描述】:

我已经阅读了很多建议、文章,但我无法解决我的问题。这是我的网址:

us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education ja/resources?id=366:video-clip

我想将此 URL 重定向到静态 URL。我试过用 .htaccess 像这样:

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/index.php

RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.feed|.pdf|.raw|/[^.]*)$ [NC]

重写规则 (.*) index.php

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

重定向 301 /tw/en/investment-opportunities/ultimate-banking-how-to-create-your-own-bank http://takeshiyashima.com/tw/investment-opportunities/ultimate-banking-how-to-create-your-own-bank

上面的 URL 已修复并且现在可以使用,但我提到的顶部 URL 不起作用。我需要帮助。

【问题讨论】:

    标签: apache .htaccess url redirect dynamic


    【解决方案1】:

    请给出一个更清晰的示例并发布正确的链接,因为不清楚“ja/resources”之前是否有任何符号以及它是否是链接的一部分。

    据我了解,您只想参与其中: '我今天想到的传统教育问题'

    并重定向到:'http://takeshiyashima.com/tw/investment-opportunities/my-thought-of-the-day-problem-of-traditional-education' 如果这是真的,这是可能的规则:

    us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education

    RewriteRule ^\/?us/my-blog\?catid=\d+id=\d+\:(.*) http://takeshiyashima.com/tw/investment-opportunities/$1 [R=301,L]
    

    未经测试,可以缩短。如果您对示例提供更多详细信息,我会尽力提供帮助。

    根据您的评论更新

    对于 ja/resources?id=366:video-clip to takeshiyashima.com/ja/resources 它是:

    RewriteRule ^\/?ja/resources.* http://takeshiyashima.com/ja/resources [R=301,L]
    

    对于 'us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education‌​n',一切都很清楚,但我在 '/ 1-my-thought',我们必须有一个清晰的模式。如果你这么说的话 你想总是从“my-thought-of-the-day-problem-of-traditional-education”中取前两个词 那么我们可以创建 '/1-my-thought',但是如果你有不同的字符串,比如 'my-stuff-education-is-cool',那么我们将无法使用正则表达式应用模式。请提供更多您想更改的原始链接(3+),以便我看看是否有任何模式。

    如果根本没有模式,则可以使用例如 RewriteMap for Apache,在服务器端有一个附加脚本,它将处理您的链接,但这是一种更复杂的方式,所以让我们坚持定期重写目前。等待 3+ 更多示例。

    【讨论】:

    • 我想将此 us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education 更改为/us/my-blog/1-my-thought/404-my-thought-of-the-day-problem-of-traditional-educationja/resources?id=366 :video-cliptakeshiyashima.com/ja/resources
    • 我有很多具有相同参数的链接,我希望全部重定向到静态页面中。以下是我想要更改的一些示例 URL:1。 us/resources?catid=72&id=354:fractional-reserve-banking 2. ja/?catid=0&id=711 3. ja/resources?id=369:seminar
    • 'RewriteRule ^\/?us/my-blog\?catid=\d+id=\d+\:(.*) takeshiyashima.com/tw/investment-opportunities/$1 [R=301,L]' 这不是工作!
    • 这是我的抓取错误报告中的所有链接 - dropbox.com/s/anvg3atbdw9aqvy/… ..
    • 这是我正在使用的 .htaccess 文件 dropbox.com/s/a718snpi2b3xe3b/.htaccess 。我无法按照您的建议重定向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-15
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多