【问题标题】:htaccess rewrite rule not working with magentohtaccess 重写规则不适用于 magento
【发布时间】:2014-09-25 06:35:55
【问题描述】:

这是重写规则在 .htaccess 中不起作用:

RewriteCond %{REQUEST_URI} ^/magento/resultados-busqueda/ 
RewriteRule resultados-busqueda/(.*) /magento/index.php/catalogsearch/result/$1 [L,QSA,NC]

如果我添加 [R] 标志,它工作正常,但没有 [R] 不起作用。

请帮忙!!

对不起我的英语。

谢谢!

【问题讨论】:

    标签: .htaccess mod-rewrite apache2


    【解决方案1】:

    事实证明新的Apache版本在某种程度上发生了变化,如果您使用的是apache 2.4,我建议您更改etc/apache2/apache2.conf文件(您需要root权限)如下:

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

    然后重启apache。

    sudo service apache2 restart
    

    它有效;)

    【讨论】:

      【解决方案2】:

      $DOCUMENT_ROOT/magento/.htaccess 中使用下面的 .htaccess sn-p:

      Options +FollowSymLinks -MultiViews
      # Turn mod_rewrite on
      RewriteEngine On
      RewriteBase /magento
      
      RewriteRule ^resultados-busqueda/([^/]+)/?$ /magento/index.php/catalogsearch/result/?q=$1 [QSA,P,NC]
      

      【讨论】:

      • Magento 是否安装在/magento 文件夹下?
      • 是的,Magento 安装在 /magento 文件夹下
      • still not working 没有提供任何信息来帮助您?你在浏览器中尝试了什么 URI?你最新的 .htaccess 是什么? (有问题的粘贴)最后你遇到了什么错误?
      • 我需要一些有关您遇到的错误的信息,例如您尝试在浏览器中打开什么 URI 以及您看到了什么错误?
      【解决方案3】:

      URI 域/magento/resultados-busqueda/pantalones 并显示错误 404。 这是我的 .htaccess:

      <IfModule mod_rewrite.c>
      
      Options +FollowSymLinks -MultiViews
      RewriteEngine On
      
      RewriteBase /magento
      
      RewriteRule ^api/rest api.php?type=rest [QSA,L]
      
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
      
      RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
      RewriteRule .* - [L,R=405]
      
      RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
      
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteRule ^resultados-busqueda/(.*)$ /magento/index.php/catalogsearch/result/?q=$1 [L,NC]
      
      RewriteRule .* index.php [L]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-12-10
        • 1970-01-01
        • 2023-03-17
        • 1970-01-01
        • 2012-11-24
        • 2020-12-02
        • 2012-12-13
        相关资源
        最近更新 更多