迁移到新主机后,Joomla 站点 URL 重写不起作用

Posted

技术标签:

【中文标题】迁移到新主机后,Joomla 站点 URL 重写不起作用【英文标题】:Joomla site URL rewriting not working after migration to new host 【发布时间】:2011-10-18 15:10:14 【问题描述】:

刚刚将此 Joomla 1.6 安装从 iPower 移至 Network Solutions。之前移动了一个 1.5 安装,没关系。这个不多。因此,当我打开 SEF 友好 URL 时,就可以了。当我打开 URL 重写以摆脱 URL 中那个烦人的 index.php 时,它说找不到页面。所以...

http://www.bigideaadv.com/a-z/index.php/about-a-and-z - 工作!

http://www.bigideaadv.com/a-z/about-a-and-z - 不起作用

注意:旧网站上一切正常...

有人有什么想法吗?

我的 HTACCESS 文件如下:

    ##
    # @version      $Id: htaccess.txt 21101 2011-04-07 15:47:33Z dextercowley $
    # @package      Joomla
    # @copyright    Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
    # @license      GNU General Public License version 2 or later; see LICENSE.txt
    ##

    ##
    # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
    #
    # The line just below this section: 'Options +FollowSymLinks' may cause problems
    # with some server configurations.  It is required for use of mod_rewrite, but may already
    # be set by your server administrator in a way that dissallows changing it in
    # your .htaccess file.  If using it causes your server to error out, comment it out (add # to
    # beginning of line), reload your site in your browser and test your sef url's.  If they work,
    # it has been set by your server administrator and you do not need it set here.
    ##



    ## Can be commented out if causes errors, see notes above.
    Options +FollowSymLinks

    ## Mod_rewrite in use.

    RewriteEngine On

    ## Begin - Rewrite rules to block out some common exploits.
    # If you experience problems on your site block out the operations listed below
    # This attempts to block the most common type of exploit `attempts` to Joomla!
    #
    # Block out any script trying to base64_encode data within the URL.
    RewriteCond %QUERY_STRING base64_encode[^(]*\([^)]*\) [OR]
    # Block out any script that includes a <script> tag in URL.
    RewriteCond %QUERY_STRING (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
    # Block out any script trying to set a PHP GLOBALS variable via URL.
    RewriteCond %QUERY_STRING GLOBALS(=|\[|\%[0-9A-Z]0,2) [OR]
    # Block out any script trying to modify a _REQUEST variable via URL.
    RewriteCond %QUERY_STRING _REQUEST(=|\[|\%[0-9A-Z]0,2)
    # Return 403 Forbidden header and show the content of the root homepage
    RewriteRule .* index.php [F]
    #
    ## End - Rewrite rules to block out some common exploits.

    ## Begin - Custom redirects
    #
    # If you need to redirect some pages, or set a canonical non-www to
    # www redirect (or vice versa), place that code here. Ensure those
    # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
    #
    ## End - Custom redirects

    ##
    # Uncomment following line if your webserver's URL
    # is not directly related to physical file paths.
    # Update Your Joomla! Directory (just / for root).
    ##

    # RewriteBase /

    ## Begin - Joomla! core SEF Section.
    #
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
    #
    # If the requested path and file is not /index.php and the request
    # has not already been internally rewritten to the index.php script
    RewriteCond %REQUEST_URI !^/index\.php
    # and the request is for something within the component folder,
    # or for the site root, or for an extensionless URL, or the
    # requested URL ends with one of the listed extensions
    RewriteCond %REQUEST_URI /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
    # and the requested path and file doesn't directly match a physical file
    RewriteCond %REQUEST_FILENAME !-f
    # and the requested path and file doesn't directly match a physical folder
    RewriteCond %REQUEST_FILENAME !-d
    # internally rewrite the request to the index.php script
    RewriteRule .* index.php [L]
    #
    ## End - Joomla! core SEF Section.

【问题讨论】:

您的主机上可能未启用 mod_rewrite .. 或 .htaccess 文件必须具有不同的名称(出于安全原因)。请联系您的托管公司并确保上述内容 - 我没有发现此文件有任何问题(在快速浏览之后)。 【参考方案1】:

就我而言,我做了两件事来启用 URL 中没有 index.php 的链接:

在您的 Apache 中安装 rewrite mod:sudo a2enmod rewrite 检查 /etc/apache2 中 apache2.conf 中的配置 选项索引 FollowSymLinks 允许覆盖所有 要求所有授予

如果你想对你的链接使用重写,拥有 AllowOverride All 是非常重要的。

这个公式适合我

【讨论】:

【参考方案2】:

我让它可以使用:RewriteBase /a-z 忘记它在子目录中。

【讨论】:

【参考方案3】:

你确定 mod_rewrite 开启了吗?

【讨论】:

RewriteEngine On -- 这样就可以了,不是吗? 没有。如果服务器上没有 mod_rewrite,这将无济于事。尝试执行&lt;?php phpinfo(); ?&gt;,查看“Apache 加载模块”部分并检查是否列出了“mod_rewrite”。 好像不是。看起来每个文件都必须实际存在,否则会出错!我正在尝试这些技巧,但无济于事。 mainelydesign.com/blog/view/… 我认为这是个坏主意。检查此***.com/questions/975262/…。使用“mod_rewrite”迁移到主机会更好。或者你可以使用像http://site.com/index.php/almost/sef/link/to/the/page这样的网址。 所谓的网络解决方案,他们说他们已经在他们的服务器上启用了它。我让它可以使用: RewriteBase /a-z 忘了它在一个子目录中。现在开始处理那些未显示的图像。

以上是关于迁移到新主机后,Joomla 站点 URL 重写不起作用的主要内容,如果未能解决你的问题,请参考以下文章

Joomla - 创建自定义重写规则

IIS URL重写不正常404错误

虚拟主机.htaccess伪静态(URL重写)建立多站点

从 Apache 2,2 迁移到 Apache 2.4 后,URL 重写不起作用

在 IIS7 上使用 Joomla 重写 URL

在 Joomla 2.5 中激活 SEO 设置后出错