如何从 URL 中删除 index.php? [英] How to remove index.php from URLs?

查看:29
本文介绍了如何从 URL 中删除 index.php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

All of my URLs on my Magento installation require index.php in them, like:

http://example.com/index.php/admin/
http://example.com/index.php/customer/account/login/

问题是系统默认链接到像

The problem is that the system by default links to URLs like

http://example.com/admin/
http://example.com/customer/account/login/

无论如何看起来更漂亮.我认为这是 .htaccess 中的重写问题,但由于过去修补这个问题给了我 500s,我想先问问你们.

Which look prettier anyway. I assume this is a rewrite issue in .htaccess, but as tinkering with that in the past has given me 500s, I'd like to ask you guys first.

更改 SEO 设置、刷新配置缓存和重新索引 URL 不起作用 此处建议.

Changing the SEO settings, flushing the configuration cache, and reindexing URLs did not work as suggested here.

推荐答案

这可能是旧的,但我还是把我学到的写下来.所以无论如何我都是这样做的.

This may be old, but I may as well write what I've learned down. So anyway I did it this way.

----------->

---------->

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

Before you start, make sure the Apache rewrites module is enabled and then follow the steps below.

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

1) Log-in to your Magento administration area then go to System > Configuration > Web.

2) 导航到不安全安全标签.确保 UnsecuredSecure - Base Url 选项在其中包含您的域名,并且不要在末尾留下正斜杠网址.示例:http://www.yourdomain.co.uk/

2) Navigate to the Unsecure and Secure tabs. Make sure the Unsecured and Secure - Base Url options have your domain name within it, and do not leave the forward slash off at the end of the URL. Example: http://www.yourdomain.co.uk/

3) 在 Web 页面上时,导航到 Search Engine Optimisation 标签并选择 Use Web Server 下方的 YES重写选项.

3) While still on the Web page, navigate to Search Engine Optimisation tab and select YES underneath the Use Web Server Rewrites option.

4) 再次导航到安全标签(如果还没有)并在在前端使用安全网址上选择> 选项.

4) Navigate to the Secure tab again (if not already on it) and select Yes on the Use Secure URLs in Front-End option.

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

5) Now go to the root of your Magento website folder and use this code for your .htaccess:

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

保存 .htaccess 并替换原始文件.(请确保在使用它之前备份您的原始 .htaccess 文件!!!)

Save the .htaccess and replace the original file. (PLEASE MAKE SURE TO BACKUP YOUR ORIGINAL .htaccess FILE BEFORE MESSING WITH IT!!!)

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

6) Now go to System > Cache Management and select all fields and make sure the Actions dropdown is set on Refresh, then submit. (This will of-course refresh the Cache.)

----------->

---------->

如果这不起作用,请按照这些额外的步骤操作.

If this did not work please follow these extra steps.

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

7) Go to System > Configuration > web again. This time look for the Current Configuration Scope and select your website from the dropdown menu. (This is of course, it is set to Default Config)

8) 确保 UnsecureSecure 字段包含与之前的默认配置文件相同的域.

8) Make sure the Unsecure and Secure fields contain the same domain as the previous Default Config file.

9) 导航到搜索引擎优化标签并选择使用网络服务器重写部分下方的.

9) Navigate to the Search Engines Optimisation tab and select Yes underneath the Use Web Server Rewrites section.

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

10) Once the URLs are the same, and the rewrite is enabled save that page, then go back and make sure they are all checked as default, then save again if needed.

11) 重复第 6 步.

11) Repeat step 6.

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

Now your index.php problem should be fixed and all should be well!!!

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

I hope this helps, and good luck.

这篇关于如何从 URL 中删除 index.php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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