gpt4 book ai didi

wordpress - WPML›子类别页面生成404 ‹WordPress

转载 作者:行者123 更新时间:2023-12-04 15:47:00 36 4
gpt4 key购买 nike

问题的简短描述

因此,问题基本上是,当我在带有wpml的网站的翻译版本中使用子类别时,它会生成404页面。在父类别中,我仍然可以看到该帖子并可以毫无问题地导航到该帖子。而且,在无翻译版本中,一切正常。

我的问题

所以我的问题是,是否还有其他人遇到过这个问题,如果有,您如何解决?

希望对您有所帮助

软件

  • PHP-5.2
  • WordPress-3.3.2
  • WPML多语言CMS-2.4.3
  • WPML字符串翻译-1.3.0

  • 固定链接设置
    /%category%/%postname%/
    我尝试过的
  • 我尝试停用所有其他插件
  • 尝试刷新永久链接 ‹编辑

  • 附加信息
  • 似乎将子类别的URL视为“页面” ‹编辑
  • 如果我们改为手动直接直接转到url,但从url中减去父类别,则将转到预期的类别存档页面 ‹编辑
    示例:http://domain.com/en/super/sub/-> http://domain.com/en/sub/

  • 我的.htaccess文件:
    # BEGIN Redirects
    RedirectMatch 301 ^/okategoriserade/(.*)$ /webb/$1
    RedirectMatch 301 ^/apache2/(.*)$ /apache/$1
    RedirectMatch 301 ^/server/(.*)$ /linux/$1
    RedirectMatch 301 ^/etiketter/(.*)$ /tag/$1
    RedirectMatch 301 ^/kategorier/(.*)$ /$1
    RedirectMatch 301 ^/en/php-en/zf2/(.*)$ /en/zf2/$1
    RedirectMatch 301 ^/media/me-avatar-e1332014347355.png(.*)$ /media/erik-landvall.png$1
    RedirectMatch 301 ^/jquery/(.*)$ /javascript/jquery/$1
    # END Redirects

    # BEGIN W3TC Browser Cache
    <IfModule mod_mime.c>
    AddType text/css .css
    AddType application/x-javascript .js
    AddType text/x-component .htc
    AddType text/html .html .htm
    AddType text/richtext .rtf .rtx
    AddType image/svg+xml .svg .svgz
    AddType text/plain .txt
    AddType text/xsd .xsd
    AddType text/xsl .xsl
    AddType text/xml .xml
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType image/bmp .bmp
    AddType application/java .class
    AddType video/divx .divx
    AddType application/msword .doc .docx
    AddType application/vnd.ms-fontobject .eot
    AddType application/x-msdownload .exe
    AddType image/gif .gif
    AddType application/x-gzip .gz .gzip
    AddType image/x-icon .ico
    AddType image/jpeg .jpg .jpeg .jpe
    AddType application/vnd.ms-access .mdb
    AddType audio/midi .mid .midi
    AddType video/quicktime .mov .qt
    AddType audio/mpeg .mp3 .m4a
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe
    AddType application/vnd.ms-project .mpp
    AddType application/x-font-otf .otf
    AddType application/vnd.oasis.opendocument.database .odb
    AddType application/vnd.oasis.opendocument.chart .odc
    AddType application/vnd.oasis.opendocument.formula .odf
    AddType application/vnd.oasis.opendocument.graphics .odg
    AddType application/vnd.oasis.opendocument.presentation .odp
    AddType application/vnd.oasis.opendocument.spreadsheet .ods
    AddType application/vnd.oasis.opendocument.text .odt
    AddType audio/ogg .ogg
    AddType application/pdf .pdf
    AddType image/png .png
    AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
    AddType audio/x-realaudio .ra .ram
    AddType application/x-shockwave-flash .swf
    AddType application/x-tar .tar
    AddType image/tiff .tif .tiff
    AddType application/x-font-ttf .ttf .ttc
    AddType audio/wav .wav
    AddType audio/wma .wma
    AddType application/vnd.ms-write .wri
    AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
    AddType application/zip .zip
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A31536000
    ExpiresByType application/x-javascript A31536000
    ExpiresByType text/x-component A31536000
    ExpiresByType text/html A3600
    ExpiresByType text/richtext A3600
    ExpiresByType image/svg+xml A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xsd A3600
    ExpiresByType text/xsl A3600
    ExpiresByType text/xml A3600
    ExpiresByType video/asf A31536000
    ExpiresByType video/avi A31536000
    ExpiresByType image/bmp A31536000
    ExpiresByType application/java A31536000
    ExpiresByType video/divx A31536000
    ExpiresByType application/msword A31536000
    ExpiresByType application/vnd.ms-fontobject A31536000
    ExpiresByType application/x-msdownload A31536000
    ExpiresByType image/gif A31536000
    ExpiresByType application/x-gzip A31536000
    ExpiresByType image/x-icon A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType application/vnd.ms-access A31536000
    ExpiresByType audio/midi A31536000
    ExpiresByType video/quicktime A31536000
    ExpiresByType audio/mpeg A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/mpeg A31536000
    ExpiresByType application/vnd.ms-project A31536000
    ExpiresByType application/x-font-otf A31536000
    ExpiresByType application/vnd.oasis.opendocument.database A31536000
    ExpiresByType application/vnd.oasis.opendocument.chart A31536000
    ExpiresByType application/vnd.oasis.opendocument.formula A31536000
    ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
    ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
    ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
    ExpiresByType application/vnd.oasis.opendocument.text A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType application/pdf A31536000
    ExpiresByType image/png A31536000
    ExpiresByType application/vnd.ms-powerpoint A31536000
    ExpiresByType audio/x-realaudio A31536000
    ExpiresByType image/svg+xml A31536000
    ExpiresByType application/x-shockwave-flash A31536000
    ExpiresByType application/x-tar A31536000
    ExpiresByType image/tiff A31536000
    ExpiresByType application/x-font-ttf A31536000
    ExpiresByType audio/wav A31536000
    ExpiresByType audio/wma A31536000
    ExpiresByType application/vnd.ms-write A31536000
    ExpiresByType application/vnd.ms-excel A31536000
    ExpiresByType application/zip A31536000
    </IfModule>
    <IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary
    </IfModule>
    <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
    </IfModule>
    </IfModule>
    <FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
    <IfModule mod_headers.c>
    Header set Pragma "public"
    Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
    <IfModule mod_headers.c>
    Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
    </FilesMatch>
    <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
    Header set Pragma "public"
    Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
    <IfModule mod_headers.c>
    Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
    </FilesMatch>
    <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
    Header set Pragma "public"
    Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
    <IfModule mod_headers.c>
    Header set X-Powered-By "W3 Total Cache/0.9.2.4"
    </IfModule>
    </FilesMatch>
    # END W3TC Browser Cache
    # BEGIN W3TC Page Cache core
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [L]
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_HOST} =erik.landvall.se
    RewriteCond %{REQUEST_URI} \/$ [OR]
    RewriteCond %{REQUEST_URI} (sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?) [NC]
    RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php) [NC,OR]
    RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass) [NC]
    RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache/0\.9\.2\.4) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -F
    RewriteRule .* "/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]
    </IfModule>
    # END W3TC Page Cache core
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
    DirectoryIndex index.php index.html index.htm

    外部资源

    外部站点上与该问题有关的信息。

    我的博客

    在我遇到问题的页面以及在我解决问题之前可以查看的页面。由于UX和SEO的原因,我从网页的翻译版本中删除了子类别。
  • 瑞典语:http://erik.landvall.se
  • 英语:http://erik.landvall.se/en

  • 目前翻译不完整,是内容差异的原因。

    wpml.org

    我在2年前发布的wplm.org上找到了一个准确描述我的问题的主题。我读了ansers,但是不幸的是,线程没有解决就结束了。

    Quoted from http://wpml.org/forums/topic/error-on-subcategories/

    there seems to be a problem with subcategories in wordpress. I'm using wordpress 2.92 and when I switch to a subcategory it shows me the 404 error page. But the posts do appear in the main category, when I switch back to it. This problems don't occur in the main language, only in the other languages. So when I'm in the main language, the posts appear under the subcategory and the main category, just not in the other languages, where they appear only in the main language.

    最佳答案

    请检查下面的更新。

    解决此问题的方法是在您的Apache配置中。您需要更改将路径转换为WordPress的index.php文件的参数的正则表达式。

    WordPress是一个在PHP上运行的非常高级的系统,它本身也是一个非常高级的系统。 WordPress无法访问到达服务器的URL。它只有其index.php文件,并且需要将请求发送到该文件,以便它可以处理该请求。

    为了实现这一点,他们使用了mod_rewrite,这是一个Apache模块,该模块在服务器决定如何处理请求之前会修改请求。

    请检查服务器的错误日志。您将看到服务器尝试访问的真实文件。另外,请检查在文件夹中创建的WordPress的.htaccess文件。在这些文件中,您将看到mod_rewrite使用的正则表达式。

    我已经检查了您的博客,看来您已经解决了这个问题。我仍然想写一本书,以便其他遇到相同问题的人也可以从中受益。特别是在看到您提到两年前其他地方的另一篇文章尚未解决之后。

    更新:

    我很高兴告诉我“我确实是,几乎是 ...”:D(指此答案的注释)看起来情况与几年前解决的情况有些不同。

    我已经检查了WordPress代码并进行了一些试验。我本来以为WordPress因为/en/而找不到该文章,但是我错了。 WordPress从URL查找帖子的默认行为涵盖了这种情况,这是一种积极的副作用:假设我没有任何插件或任何语言,因此/en/对WordPress毫无意义。

    当我想浏览到erik.landvall.se/en/时,它按预期返回404。但是,如果我们有一个类别结构(如abc/cde/efg/)和一个文章(如moo),可以在abc/cde/efg/moo处进行访问;当我更改链接的类别部分时,WordPress会自动将我重定向到abc/cde/efg/moo:
    en/abc/cde/efg/mooabc/efg/moocde/efg/moo...

    全部重定向到abc/cde/efg/moo。在您的博客上,我看到了相同的行为,除了en/会使您的插件出现在场景中。现在很明显,插件以与WordPress最初不同的方式处理URL结构或以另一种方式导致原始行为发生变化。

    我想按照我的 promise 检查插件来源;但是我发现现在对我来说是不可能的,因为我必须购买该产品才能看到货源,而且我不愿意购买我永远不会使用的东西:)

    由于您说的是“在父类别中,我仍然可以看到该帖子并可以毫无问题地导航到该帖子。”我以为从网址中删除子类别。这是一个非常肮脏的技巧。但比编辑插件更好。

    我们将这个丑陋的php文件fix_lang_subcategory.php放到我们的根文件夹中:

    <?php

    function fix_lang_subcategory() {
    $p = trim($_SERVER['REDIRECT_URL'], '/');
    if (substr_count($p, '/') > 2) {
    $_SERVER['REQUEST_URI']='/'.substr($p, 0, strpos($p,'/',4)).'/'.substr($p, strrpos($p, '/')+1).'/'.($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '');
    }
    };
    fix_lang_subcategory();
    require_once('index.php');
    ?>

    之后,您应该可以在/fix_lang_subcategory.php上成功看到WordPress的404文件。如果可行,我们可以编辑.htaccess文件。

    在您的.htaccess文件末尾,
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    行,我们添加以下行:
    RewriteRule ^en/ /fix_lang_subcategory.php [L]

    我们在这里所做的是,我们使用来自wordpress的index.php的愚蠢php文件更改了入口点,以便能够运行几行php而无需接触原始资源。这仅适用于网站的/en/部分。休息就像现在一样工作。在我们的php文件中,我们检查是否看到带有子类别的链接,如果存在,则进行更改(这不是一件好事!)REQUEST_URI,如下所示:
    /en/maincategory/subcategory1/subcategory2/article/?anything_here_untouched


    /en/maincategory/article/?anything_here_untouched

    然后我们让WordPress正常工作。

    如果启用子类别时插件的工作方式不同,则这可能导致/en/下的子类别页面重定向。

    一个更好的解决方案:

    我以为您不想将子域用于替代语言;但是然后我看到“您可以在子目录/子域中托管翻译博客的版本吗?”在对您的问题的评论以及您的答复中,似乎提到子目录引起了误会。正如我在ML插件的网站上看到的那样,您可以使用子域而不是文件夹,这可以免除所有麻烦,可能是:

    除了 http://erik.landvall.se/en外,您还可以使用 http://en.erik.landvall.se/吗?也许?

    更好的解决方案:

    ML插件导致此问题的可能性高达90%,因此他们必须对其进行修复。发出支持通知单可能有助于他们了解问题并为其他所有人解决。

    关于wordpress - WPML›子类别页面生成404 ‹WordPress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10568616/

    36 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com