【问题标题】:500 Internal Server Error is coming when i'm redirecting my normal page to AMP page htaccess error当我将正常页面重定向到 AMP 页面 htaccess 错误时,出现 500 内部服务器错误
【发布时间】:2018-08-06 15:51:00
【问题描述】:

这是我的重定向 AMP 页面的正常页面代码。

<meta name="original-source" content="https://www.themobilesapp.com/<?= $abc; ?>">
<link rel="canonical" href="https://www.themobilesapp.com/<?= $abc; ?>">
<link rel="amphtml" href="https://www.themobilesapp.com/ampspecification/<?= $abc; ?>">

正常的页面网址是 https://www.themobilesapp.com/Nokia-Lumia-638-specifications-3029

这工作正常,AMP 页面网址不起作用https://www.themobilesapp.com/ampspecification/Nokia-Lumia-638-specifications-3029 但是当我添加 ampspecification.php 和其他传递时,这个放大器工作正常。

但是当访问 AMP 页面 url 时,它会向我显示以下错误:-

Internal Server Error 服务器遇到内部错误或 配置错误,无法完成您的请求。请 通过 webmaster@themobilesapp.com 联系服务器管理员以 告知他们此错误发生的时间,以及您采取的措施 在此错误之前执行。有关此错误的更多信息 可能在服务器错误日志中可用。此外,一个 500 内部 尝试使用服务器时遇到服务器错误错误 ErrorDocument 来处理请求。

包含所有代码的 htaccess 文件

Options +FollowSymLinks -MultiViews -Indexes

<IfModule mod_rewrite.c>

DirectoryIndex index.php

RewriteCond %{HTTP_HOST} ^themobilesapp.com$ [NC]
RewriteRule (.*) https://www.themobilesapp.com/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

ErrorDocument 404 404error.php

RewriteRule ^([A-Za-z0-9-]+)$ specification.php?abc=$1 [L]

RewriteRule ^news/([A-Za-z0-9-]+)?$ news.php?abc=$1 [L]

RewriteRule ^ampnews/([A-Za-z0-9-]+)?$ ampnews.php?abc=$1 [L]

RewriteRule ^profile/([A-Za-z0-9-]+)?$ profile.php?id=$1 [L]

</IfModule>

【问题讨论】:

标签: .htaccess url url-rewriting url-redirection


【解决方案1】:

你必须为这种情况写一个特定的规则,请在下面尝试,让我知道结果。

RewriteRule ^ampspecification/([A-Za-z0-9-]+)$ ampspecification.php/$1 [L]

我假设您想将页面重写为 ampspecification.php/test_url。

在上面我们正在重写开始时具有“ampspecification”的url。

编辑:

RewriteRule ^ampspecification/([A-Za-z0-9-]+)$ specification.php?abc=$1 [L]

【讨论】:

  • 你想要重写的原始网址是什么?
  • 我也试试这个 RewriteRule ^ampspecification/([A-Za-z0-9-]+)?$ ampspecification.php?url=$1 [L] 但是这个不工作...
  • 这是原始网址themobilesapp.com/Nokia-Lumia-638-specifications-3029,为此我使用您推荐的代码 RewriteRule ^([A-Za-z0-9-]+)$ specification.php?url=$1 [ L]
  • 没有兄弟。它不工作。顺便说一句,在您的帮助下,整个 .htaccess 代码正在我的网站上运行。
  • 兄弟。我没有在 **ampspecification.php 页面上重定向 specification.php* 页面。 ampspecification.php 页面是 Google AMP 的另一个页面,用于更好的移动搜索结果。普通页面themobilesapp.com/ampspecification/…,这是AMP页面themobilesapp.com/ampspecification/…
【解决方案2】:
RewriteRule ^ampspecification/([A-Za-z0-9-]+) /ampspecification.php?abc=$1 [L]

此代码行解决了我的问题。

【讨论】:

    猜你喜欢
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多