Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何从URL中删除index.php?_.htaccess_Magento_Url Rewriting_E Commerce - Fatal编程技术网

.htaccess 如何从URL中删除index.php?

.htaccess 如何从URL中删除index.php?,.htaccess,magento,url-rewriting,e-commerce,.htaccess,Magento,Url Rewriting,E Commerce,Magento安装中的所有URL都需要index.php,如: http://example.com/index.php/admin/ http://example.com/index.php/customer/account/login/ 问题是系统默认链接到URL,如 http://example.com/admin/ http://example.com/customer/account/login/ 那看起来更漂亮。我想这是.htaccess中的一个重写问题,但在过去修补这个问题给了

Magento安装中的所有URL都需要index.php,如:

http://example.com/index.php/admin/
http://example.com/index.php/customer/account/login/
问题是系统默认链接到URL,如

http://example.com/admin/
http://example.com/customer/account/login/
那看起来更漂亮。我想这是.htaccess中的一个重写问题,但在过去修补这个问题给了我500分,我想先问问你们


更改SEO设置、刷新配置缓存和重新索引URL都不起作用。

在.htaccess中如何:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

遵循以下步骤,它将帮助您

步骤1:转到站点根文件夹,您可以在那里找到
.htaccess
文件。用文本编辑器打开它,找到行
#RewriteBase/magento/
。只需将其替换为#RewriteBase/只需取出“magento/”即可

步骤2:然后转到管理面板并启用重写(设置以使用Web服务器重写)。您可以在系统->配置->网络->搜索引擎优化中找到它


步骤3:然后转到缓存管理页面(系统缓存管理),刷新缓存并刷新以检查站点。

您必须在apache中启用mod_rewrite以使干净的URL正常工作

如果mod_rewrite不在phpinfo中,则必须在

sudo a2enmod rewrite
sudo apache2ctl -l
您需要将出现的
AllowOverride none
替换为
AllowOverride all
(在/etc/apache2/sites enabled/000默认值中)

重新启动Apache

sudo service apache2 restart

在Magento的管理中,转到
系统>配置>网络>搜索引擎优化
并将“
使用Web服务器重写
”更改为“是”

我在帖子中尝试了所有内容,但都没有成功。 然后,我将ErJab提供的.htaccess代码片段更改为:

RewriteRule ^(.*)$ 'folder_name'/index.php/$1 [L]
上面这条线给我修好了。其中*folder_name*是magento根文件夹


希望这有帮助

嗨,我来晚了。。我只是想指出,来自的说明真的很有用

我在Ubuntu服务器上安装了Apache、MySql和Php,所以我想我可以跳转到标题创建Magento将从中提供服务的目录,我遇到了与OP相同的问题,即我在所有URL中都需要“index.Php”(或者我会得到404未找到)。然后我回到安装和配置ApacheHTTP服务器的,在重新启动Apache之后,它工作得非常好

作为参考,我遗漏了:

sudo bash -c "cat >> /etc/apache2/conf.d/servername.conf <<EOF
ServerName localhost
EOF"

希望这能有所帮助这可能很旧,但我还是把我学到的写下来吧。 所以不管怎样,我是这样做的

---------->

开始之前,请确保启用了Apache重写模块,然后按照以下步骤操作

1) 登录到您的Magento管理区域,然后转到系统>配置>Web

2) 导航到不安全安全选项卡。确保不安全安全-基本Url选项中包含您的域名,并且不要在Url末尾保留正斜杠。例如:

3) 当仍在Web页面上时,导航到搜索引擎优化选项卡,并在使用Web服务器重写选项下方选择

4) 再次导航到安全选项卡(如果没有),并在前端使用安全URL选项上选择

5) 现在转到Magento网站文件夹的根目录,并将此代码用于.htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
保存.htaccess并替换原始文件(在处理原始.htaccess文件之前,请确保对其进行备份!!!)

6) 现在转到系统>缓存管理并选择所有字段,确保操作下拉菜单设置为刷新,然后提交。(这当然会刷新缓存。)

---------->

如果这不起作用,请执行这些额外步骤

7) 再次转到系统>配置>web。这一次,查找当前配置范围,并从下拉菜单中选择您的网站。(当然,这是默认配置)

8) 确保不安全安全字段包含与先前默认配置文件相同的域

9) 导航到搜索引擎优化选项卡,并在使用Web服务器重写部分下方选择

10) 一旦URL相同,并且启用了重写,请保存该页面,然后返回并确保它们都被选中为默认值,如果需要,请再次保存

11) 重复步骤6

现在你的index.php问题应该已经解决了,一切都应该很好


我希望这会有所帮助,祝你好运。

如果其他解决方案对你不起作用,请尝试以下方法:

步骤1:(如果您的安装在webroot中)

替换

    #RewriteBase /magento/

第二步:

添加以下行(包括排除管理员,因为后端内部需要index.php)

紧接着

RewriteRule .* index.php [L] 
这对我有用

如果仍不工作,请再次检查Magento配置:
系统->配置->网络->搜索引擎优化。必须启用重写。

主要是在您使用基于Linux的系统(如“Ubuntu”)时,这只建议本地主机用户使用,而不建议服务器使用

按照前面答案中提到的所有步骤进行操作

为它签入Apache配置。(允许超越所有) 如果AllowOverride值为none,则将其更改为All并重新启动apache

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

选项索引跟随符号链接
允许超越所有
需要所有gra
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
<IfModule mod_rewrite.c>

############################################
## enable rewrites

Options +FollowSymLinks
RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

#RewriteBase /

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]