Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
Regex Magento htaccess重写和重定向_Regex_.htaccess_Magento - Fatal编程技术网

Regex Magento htaccess重写和重定向

Regex Magento htaccess重写和重定向,regex,.htaccess,magento,Regex,.htaccess,Magento,在一个基于Magento的电子商务网站上,我试图从URL中删除index.php,并将非www重定向到www 默认URL:www.example.com/index.php/super-cool-product.html 所需产品URL:www.example.com/super-cool-Product.html 也可以301将非www重定向到www: example.com/super cool product.html 致: www.example.com/super-cool-produ

在一个基于Magento的电子商务网站上,我试图从URL中删除index.php,并将非www重定向到www

默认URL:www.example.com/index.php/super-cool-product.html

所需产品URL:www.example.com/super-cool-Product.html

也可以301将非www重定向到www:
example.com/super cool product.html
致:
www.example.com/super-cool-product.html

以及:
www.example.com/index.html
致:
www.example.com

这就是我目前拥有的:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301]

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.rejuvahealth.com/$1 [R=301,NC,L]

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.rejuvahealth.com/$1 [R=301,NC,L]

要重定向index.html,请执行以下操作:

Options +FollowSymLinks
RewriteEngine on
redirect 301 /index.html http://www.example.co.uk/
如果正确配置基本URL,则Magento应自动重定向到www.com版本

对于index.php重写,请转到配置>Web>使用Web服务器重写并更改为“是”

现在打开htaccess并更改此行:

#RewriteBase /magento/
为此:

RewriteBase /

假设您的Magento文件夹位于根目录上。不过,在使用web重写时要小心,并确保在进行任何更改之前进行备份。

您不会说什么地方出了问题,所以我认为您所做的工作是有效的。祝你成功!我无法让它工作:
redirect 301/index.htmlhttp://www.example.co.uk/
但是找到它可以通过转到
目录>URL重写管理进行设置
感谢您的帮助!