没有 index.php,除主页之外的 Magento URL 无法工作 [英] Magento URLs other than home page do not work without index.php

查看:20
本文介绍了没有 index.php,除主页之外的 Magento URL 无法工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 magento 安装在 Ubuntu Linux 的/var/www/magento 下.这个问题看起来像档案里的一些问题但实际上有些不同.当我安装 Magento 时Ubuntu Linux 我启用了 Apache mod_rewrite URL 重写.

My magento is installed on Ubuntu Linux under /var/www/magento . This question looks like some of the questions in the archives but is acutally somewhat different. When I installed Magento on Ubuntu Linux I enabled Apache mod_rewrite URL rewrites.

当我访问 http://localhost/magento 时我的服务器将 URL 重写为 http://localhost/magento/并显示页面.然后我点击其中一个链接在导航栏中,假设它是导航栏项目foo".然后 magento 带我去:

When I go to http:// localhost/magento my server rewrites the URL as http:// localhost/magento/ and displays the page. I then click on one of the links in the navigation bar, let's say it's nav-bar item "foo". Then magento takes me to:

http://localhost/magento/foo.html

http:// localhost/magento/foo.html

显示未找到"的 apache 页面.

which displays a "Not Found" apache page.

我得把网址改成----->

I have to change the URL to ----->

http://localhost/magento/index.php/foo.html

http:// localhost/magento/index.php/foo.html

为了显示页面.

我的 mod_rewrite 工作好像出了点问题.

It is as though something is amiss in my mod_rewrite workings.

谢谢,

约翰·戈什

配置:系统 -> 配置 ->(通用 ->)网页:

CONFIGURATION: System -> Configuration -> (General ->) Web:

使用 Web 服务器重写:是

Use Web Server Rewrites: YES

基本网址:http://localhost/magento

Base URL: http:// localhost/magento

如果我将User Web Server Rewrites:"设置为 NO,那么链接从我的主页工作正常,但看到页面http://localhost/magento/index.php/foo.html显示正确的页面,但是该网站有效,我不喜欢该网址.一世希望它是 http://localhost/magento/foo.html没有 index.php 位,因为这也可能对搜索引擎优化更友好.

If I set "User Web Server Rewrites:" to NO, then the links from my main page work fine, but see the page http:// localhost/magento/index.php/foo.html which displays the correct page, but whereas the website works I don't like the URL. I would like it to be http:// localhost/magento/foo.html without the index.php bit, as this would also probably be more SEO-friendly.

谢谢,

约翰·戈什

更新:我尝试取消对我的人工 127.0.1.1 IP 地址的注释哪个 ubuntu 已放入/etc/hosts 并将我的真实 IP 放在那里,但是没有运气.我仍然有完全相同的问题.还有里面的网址我的浏览器被重写为 http://localhost/等...每当我在其中输入 192.168.3.31、avalanche 或 avalanche.com.我还在想办法解决问题如上所述,因为这没有做到.

Update: I've tried uncommenting my artificial 127.0.1.1 IP address which ubuntu had put in /etc/hosts and placing ther my real IP but no luck. I still have exactly the same problem. And the URL inside my browser is rewritten to http:// localhost / etc... whenver I type 192.168.3.31, avalanche, or avalanche.com inside it. I am still trying to figure out how to solve the problem described above as this did not do it.

127.0.0.1       localhost
#127.0.1.1      avalanche

192.168.4.35    avalanche avalanche.com

当我重新启动 Apache 时,我得到:

When I restart Apache I get:

# service apache2 restart
 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.4.35 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.4.35 for ServerName

不知道如何解决原来的问题.我正在本地服务器上进行测试.

Not sure how to fix the original issue. I am testing on a local server.

我什至尝试过这个解决方案,然后重新启动了 apache2,但没有运气!

I've even tried this solution and then restarted apache2, but no luck!

如何从 URL 中删除 index.php?

如此放置:

RewriteEngine On
RewriteBase /mymagento/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

不起作用,即使使用 RewriteBase/,也不起作用.

does not work, even with RewriteBase /, it does not work.

好的,最后我设法解决了问题.文件/etc/apache2/sites-enabled/000-default为所有目录设置了以下指令在此文件中定义:

OK, finally I managed to solve the probkem. The file /etc/apache2/sites-enabled/000-default has the following directive set for all directories defined within this file:

 AllowOverride None

例如,对于/var/www 这是默认的文档根目录在 Ubuntu 12.04 LTS Linux 系统上设置此文件包含

For instance, for /var/www which is the default document root set on Ubuntu 12.04 LTS Linux system this file contains

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

据我所知,这意味着 .htaccess 文件在不会解析此目录及其所有子目录.要解决此问题,只需设置:

which as far as I understand means that .htaccess files found in this directory and all of its subdirectories will not be parsed. To fix the problem it is sufficient to set:

AllowOverride All

意味着您将能够覆盖服务器配置指令在/etc/apache2/apache2.conf (或/etc/apache2/httpd.conf 中找到包括在其中).

meaning you will be able to override the server configuration directives found in /etc/apache2/apache2.conf (or /etc/apache2/httpd.conf which is included therein).

默认情况下 AllowOverride 设置为 None 的原因之一可能是它会减慢服务器的速度,另一个是出于安全原因.这指令应设置在标签内,并且后者可以覆盖前者.这不是的另一个原因默认设置是必须递归解析 .htaccess每次目录路径中的文件在整个站点中加载会减慢系统速度,从而放置/etc/apache2/httpd.conf 中的 .htaccess 内容时可能是值得推荐的,因为它可能会导致速度提升.

One of the reasons AllowOverride is set to None by default could be that it slows down the server and the other is for security reasons. This directive should be set inside a tag and the latter ones can override the former. Another reason this is not set by default is that having to parse .htaccess recursively across the site each time a file in a directory path is loaded can slow down the system and thus placing the .htaccess stuff in /etc/apache2/httpd.conf when possible is recommendable as it can cause an increase in speed.

所以地方

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            #AllowOverride None
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

在/etc/apache2/sites-enabled/000-default 里面

inside /etc/apache2/sites-enabled/000-default

并运行:service apache2 restart

and run: service apache2 restart

就是解决方案.

推荐答案

您是否尝试过:

RewriteBase /magento/

而不是 RewriteBase/mymagento/因为你的 url 是 http://localhost/magento/

and not RewriteBase /mymagento/ because your url is http:// localhost/magento/

您的 apache 虚拟主机是否允许覆盖配置,例如

Does your apache virtual host allow to overwrite the config, e.g.

<VirtualHost *:80>
...
<Directory /var/www/magento/>
    AllowOverride All
</Directory>
</VirtualHost>

这篇关于没有 index.php,除主页之外的 Magento URL 无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆