没有index.php,首页以外的Magento URL无法正常工作 [英] Magento URLs other than home page do not work without index.php

查看:119
本文介绍了没有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.

我必须将URL更改为----->

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.

谢谢

John Goche

John Goche

配置:系统->配置->(常规->)网络:

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

使用Web服务器重写:是

Use Web Server Rewrites: YES

基本URL:http://localhost/magento

Base URL: http:// localhost/magento

如果我将用户Web服务器重写:"设置为否",则链接 从我的主页工作正常,但请参见页面 http://localhost/magento/index.php/foo.html 显示正确的页面,但是 该网站可以正常运行,但我不喜欢该网址.一世 希望它是http://localhost/magento/foo.html 没有index.php位,因为这也可能 更加适合SEO.

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.

谢谢,

John Goche

John Goche

更新:我尝试取消对人工127.0.1.1 IP地址的注释 哪个ubuntu放进/etc/hosts并放置我的真实IP,但是 没运气.我仍然有完全相同的问题.还有里面的URL 每当我将浏览器重写为http://localhost/etc时 在其中输入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!

如何从网址中删除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/,因为您的网址是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天全站免登陆