如何删除索引。php从url ?

时间:2021-09-29 04:19:18

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

我在Magento安装上的所有url都需要索引。php,如:

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

问题是系统默认地链接到url

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

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.

它看起来更漂亮。我认为这是。htaccess中的一个重写问题,但是由于过去对这个问题的修补给了我500s,我想先问问你们。

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

更改SEO设置、刷新配置缓存和索引url都不能像这里建议的那样工作。

8 个解决方案

#1


84  

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

这可能是老生常谈了,但我不妨把我学到的东西写下来。总之,我是这么做的。

---------->

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

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

在开始之前,请确保启用了Apache重写模块,然后按照下面的步骤进行操作。

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

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

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/

2)导航到不安全、不安全的选项卡。确保不安全且安全的基础Url选项中包含您的域名,并且不要在Url的末尾留下斜杠。例如:http://www.yourdomain.co.uk/

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

3)当仍然在Web页面上时,导航到搜索引擎优化选项卡,并在Use Web Server rewrite选项下选择YES。

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

4)再次导航到Secure选项卡(如果还没有),并在前端选项中的Use Secure url上选择Yes。

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

5)现在转到Magento网站文件夹的根目录,并使用此代码进行.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>

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

保存.htaccess并替换原始文件。(请先备份你原来的。htaccess文件,然后再把它弄乱!!)

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.)

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

---------->

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

If this did not work please follow these extra steps.

如果这不起作用,请遵循这些额外的步骤。

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)

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

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

8)确保Unsecure和Secure字段包含与先前默认配置文件相同的域。

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

9)导航到搜索引擎优化选项卡,并在Use Web Server rewrite部分下选择Yes。

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.

10)一旦url是相同的,并且重写被启用,保存该页面,然后返回并确保它们都被检查为默认值,然后在需要时再次保存。

11) Repeat step 6.

11)重复步骤6。

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

现在你的索引。php的问题应该是固定的,所有的都应该是好的!!!

I hope this helps, and good luck.

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

#2


25  

Follow the below steps it will helps you.

遵循以下步骤,它将帮助你。

step 1: Go to to your site root folder and you can find the .htaccess file there. Open it with a text editor and find the line #RewriteBase /magento/. Just replace it with #RewriteBase / take out just the 'magento/'

步骤1:进入你的站点根文件夹,你可以在那里找到。htaccess文件。使用文本编辑器打开它,找到#RewriteBase /magento/行。只需用#RewriteBase替换它/去掉“magento/”

step 2: Then go to your admin panel and enable the Rewrites(set yes for Use Web Server Rewrites). You can find it at System->Configuration->Web->Search Engine Optimization.

步骤2:然后转到您的管理面板并启用重写(为Use Web Server rewrite设置yes)。您可以在系统->配置->Web->搜索引擎优化中找到它。

step 3: Then go to Cache management page (system cache management ) and refresh your cache and refresh to check the site.

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

#3


9  

You have to enable mod_rewrite in apache to make clean urls to work

您必须在apache中启用mod_rewrite来让干净的url生效

if mod_rewrite is not in phpinfo you have to install it by

如果mod_rewrite在phpinfo文件中没有,你必须先安装它

sudo a2enmod rewrite
sudo apache2ctl -l

You need to replace the occurrence of AllowOverride none to AllowOverride all ( in /etc/apache2/sites-enabled/000-default)

您需要替换AllowOverride none的出现以允许覆盖all(在/etc/apache2/sites-enabled/000-default中)

Restart Apache

重新启动Apache

sudo service apache2 restart

In Magento’s admin go to System > Configuration > Web > search engine Optimization and change “Use Web Server Rewrites” to Yes

在Magento 's admin中进入系统>配置> Web >搜索引擎优化并将“使用Web服务器重写”改为“Yes”

#4


7  

How about this in your .htaccess:

在你的。htaccess中:

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

#5


2  

Hi I'm late to the party.. just wanted to point out that the instructions from http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/ were really useful.

嗨,我来晚了。我只想指出http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/的说明非常有用。

I had Ubuntu server installed with Apache, MySql and Php so I thought I could jump to the heading Creating the directory from which Magento will be served from and I reached the same problem as the OP, i.e. I had 'index.php' needed in all the URLs (or I would get 404 not found). I then went back to Installing and configuring the Apache HTTP server and after restarting apache it works perfectly.

我安装了Apache、MySql和Php的Ubuntu服务器,所以我想我可以跳转到创建Magento服务目录的标题,我遇到了与OP相同的问题,即“索引”。所有url中都需要php(否则我就找不到404了)。然后我重新安装和配置Apache HTTP服务器,在重新启动Apache之后,它工作得非常好。

For reference, I was missing:

作为参考,我遗漏了:

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

... and

…和

sudo a2enmod rewrite
sudo service apache2 restart

Hope this helps

希望这有助于

#6


2  

If the other solutions don't work for you, try this:

如果其他的方法对你不起作用,试试这个:

Step 1: (if your installation is in webroot)

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

Replace

取代

    #RewriteBase /magento/

with

    RewriteBase /

Step 2:

步骤2:

Add following lines (inclusive exclude admin because backend needs index.php internally)

添加以下行(包含排除管理,因为后端需要索引。php内部)

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]
RewriteRule ^index.php/(admin|user)($|/) - [L]
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

right after

之后

RewriteRule .* index.php [L] 

This works for me

这适合我

In case it is still not working, double check Magento configuration: System->Configuration->Web->Search Engine Optimization. Rewrites must be enabled.

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

#7


1  

I tried everything on the post but nothing had worked. I then changed the .htaccess snippet that ErJab put up to read:

我试过了所有的方法,但都没有用。然后,我更改了ErJab放置的.htaccess代码片段如下:

RewriteRule ^(.*)$ 'folder_name'/index.php/$1 [L]

The above line fixed it for me. where *folder_name* is the magento root folder.

上面的线帮我修好了。其中*folder_name*是magento根文件夹。

Hope this helps!

希望这可以帮助!

#8


1  

Mainly If you are using Linux Based system Like 'Ubuntu' and this is only suggested for localhost user not for the server.

如果您使用的是基于Linux的系统,比如“Ubuntu”,那么建议只针对本地主机用户,而不是服务器。

Follow all the steps mentioned in the previous answers. +

遵循前面回答中提到的所有步骤。+

Check in Apache configuration for it. (AllowOverride All) If AllowOverride value is none then change it to All and restart apache again.

检查Apache配置。(AllowOverride All)如果AllowOverride值为none,则将其更改为All并重新启动apache。

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

Let me know if this step help anyone. As it can save you time if you find it earlier.

如果这一步对任何人都有帮助,请告诉我。因为如果你早点找到它,它可以节省你的时间。

如何删除索引。php从url ?

I am adding the exact lines from my htaccess file in localhost. for your reference

我正在从本地主机的htaccess文件中添加确切的行。供你方参考

Around line number 110

行号110

<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]

Images are for some user who understand easily from image the from the text:

图片是为一些用户提供的,他们可以很容易地从图片中理解文字:

如何删除索引。php从url ?

#1


84  

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

这可能是老生常谈了,但我不妨把我学到的东西写下来。总之,我是这么做的。

---------->

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

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

在开始之前,请确保启用了Apache重写模块,然后按照下面的步骤进行操作。

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

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

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/

2)导航到不安全、不安全的选项卡。确保不安全且安全的基础Url选项中包含您的域名,并且不要在Url的末尾留下斜杠。例如:http://www.yourdomain.co.uk/

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

3)当仍然在Web页面上时,导航到搜索引擎优化选项卡,并在Use Web Server rewrite选项下选择YES。

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

4)再次导航到Secure选项卡(如果还没有),并在前端选项中的Use Secure url上选择Yes。

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

5)现在转到Magento网站文件夹的根目录,并使用此代码进行.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>

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

保存.htaccess并替换原始文件。(请先备份你原来的。htaccess文件,然后再把它弄乱!!)

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.)

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

---------->

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

If this did not work please follow these extra steps.

如果这不起作用,请遵循这些额外的步骤。

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)

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

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

8)确保Unsecure和Secure字段包含与先前默认配置文件相同的域。

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

9)导航到搜索引擎优化选项卡,并在Use Web Server rewrite部分下选择Yes。

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.

10)一旦url是相同的,并且重写被启用,保存该页面,然后返回并确保它们都被检查为默认值,然后在需要时再次保存。

11) Repeat step 6.

11)重复步骤6。

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

现在你的索引。php的问题应该是固定的,所有的都应该是好的!!!

I hope this helps, and good luck.

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

#2


25  

Follow the below steps it will helps you.

遵循以下步骤,它将帮助你。

step 1: Go to to your site root folder and you can find the .htaccess file there. Open it with a text editor and find the line #RewriteBase /magento/. Just replace it with #RewriteBase / take out just the 'magento/'

步骤1:进入你的站点根文件夹,你可以在那里找到。htaccess文件。使用文本编辑器打开它,找到#RewriteBase /magento/行。只需用#RewriteBase替换它/去掉“magento/”

step 2: Then go to your admin panel and enable the Rewrites(set yes for Use Web Server Rewrites). You can find it at System->Configuration->Web->Search Engine Optimization.

步骤2:然后转到您的管理面板并启用重写(为Use Web Server rewrite设置yes)。您可以在系统->配置->Web->搜索引擎优化中找到它。

step 3: Then go to Cache management page (system cache management ) and refresh your cache and refresh to check the site.

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

#3


9  

You have to enable mod_rewrite in apache to make clean urls to work

您必须在apache中启用mod_rewrite来让干净的url生效

if mod_rewrite is not in phpinfo you have to install it by

如果mod_rewrite在phpinfo文件中没有,你必须先安装它

sudo a2enmod rewrite
sudo apache2ctl -l

You need to replace the occurrence of AllowOverride none to AllowOverride all ( in /etc/apache2/sites-enabled/000-default)

您需要替换AllowOverride none的出现以允许覆盖all(在/etc/apache2/sites-enabled/000-default中)

Restart Apache

重新启动Apache

sudo service apache2 restart

In Magento’s admin go to System > Configuration > Web > search engine Optimization and change “Use Web Server Rewrites” to Yes

在Magento 's admin中进入系统>配置> Web >搜索引擎优化并将“使用Web服务器重写”改为“Yes”

#4


7  

How about this in your .htaccess:

在你的。htaccess中:

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

#5


2  

Hi I'm late to the party.. just wanted to point out that the instructions from http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/ were really useful.

嗨,我来晚了。我只想指出http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/的说明非常有用。

I had Ubuntu server installed with Apache, MySql and Php so I thought I could jump to the heading Creating the directory from which Magento will be served from and I reached the same problem as the OP, i.e. I had 'index.php' needed in all the URLs (or I would get 404 not found). I then went back to Installing and configuring the Apache HTTP server and after restarting apache it works perfectly.

我安装了Apache、MySql和Php的Ubuntu服务器,所以我想我可以跳转到创建Magento服务目录的标题,我遇到了与OP相同的问题,即“索引”。所有url中都需要php(否则我就找不到404了)。然后我重新安装和配置Apache HTTP服务器,在重新启动Apache之后,它工作得非常好。

For reference, I was missing:

作为参考,我遗漏了:

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

... and

…和

sudo a2enmod rewrite
sudo service apache2 restart

Hope this helps

希望这有助于

#6


2  

If the other solutions don't work for you, try this:

如果其他的方法对你不起作用,试试这个:

Step 1: (if your installation is in webroot)

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

Replace

取代

    #RewriteBase /magento/

with

    RewriteBase /

Step 2:

步骤2:

Add following lines (inclusive exclude admin because backend needs index.php internally)

添加以下行(包含排除管理,因为后端需要索引。php内部)

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]
RewriteRule ^index.php/(admin|user)($|/) - [L]
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

right after

之后

RewriteRule .* index.php [L] 

This works for me

这适合我

In case it is still not working, double check Magento configuration: System->Configuration->Web->Search Engine Optimization. Rewrites must be enabled.

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

#7


1  

I tried everything on the post but nothing had worked. I then changed the .htaccess snippet that ErJab put up to read:

我试过了所有的方法,但都没有用。然后,我更改了ErJab放置的.htaccess代码片段如下:

RewriteRule ^(.*)$ 'folder_name'/index.php/$1 [L]

The above line fixed it for me. where *folder_name* is the magento root folder.

上面的线帮我修好了。其中*folder_name*是magento根文件夹。

Hope this helps!

希望这可以帮助!

#8


1  

Mainly If you are using Linux Based system Like 'Ubuntu' and this is only suggested for localhost user not for the server.

如果您使用的是基于Linux的系统,比如“Ubuntu”,那么建议只针对本地主机用户,而不是服务器。

Follow all the steps mentioned in the previous answers. +

遵循前面回答中提到的所有步骤。+

Check in Apache configuration for it. (AllowOverride All) If AllowOverride value is none then change it to All and restart apache again.

检查Apache配置。(AllowOverride All)如果AllowOverride值为none,则将其更改为All并重新启动apache。

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

Let me know if this step help anyone. As it can save you time if you find it earlier.

如果这一步对任何人都有帮助,请告诉我。因为如果你早点找到它,它可以节省你的时间。

如何删除索引。php从url ?

I am adding the exact lines from my htaccess file in localhost. for your reference

我正在从本地主机的htaccess文件中添加确切的行。供你方参考

Around line number 110

行号110

<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]

Images are for some user who understand easily from image the from the text:

图片是为一些用户提供的,他们可以很容易地从图片中理解文字:

如何删除索引。php从url ?