我有一个Magento站点安装在像http-host/subdir1/subdir2/siterootdir这样的子文件夹中。
现在我想缩短我的品牌页面的一个相当长的URL,如下所示:
请求URL:
http://hostname/subdir1/subdir2/siterootdir/brands/brandname.html
至
原始网址:
http://hostname/subdir1/subdir2/siterootdir/brands/index/brandsproduct/brand/brandname
使用动态查询字符串重定向htaccess。
我尝试过很多谷歌搜索的例子,但是当我运行我所需的请求URL (如上面所示)时,我一直在获取404 not found页面。
另外,我不太擅长正则化和重写规则/条件,那么谁能为上述问题提供解决方案,并解释其背后的细节?
请注意,当然,brandname是动态的。
发布于 2015-05-19 12:21:32
为了解决这些问题,我采取了一种不同的方法,因为我只需要重写特定品牌的URL,所以它与htaccess场景没有完全的关系,所以我稍微改变了一些方法&每当从管理员中保存任何品牌时,rewrite programmatically是否都会重写(“自定义”类型),我也不希望浏览器中的URL发生变化,这是由magento重写提供的。
尽管有人用"htaccess“的方式找到了解决方案,但我仍然对此持开放态度,因为我不必为创建url重写而保存每一个品牌。
发布于 2015-05-19 09:36:05
这个.htaccess文件将把http://hostname/subdir1/subdir2/siterootdir/brands/brandname.html重定向到http://hostname/subdir1/subdir2/siterootdir/brands/index/brandsproduct/brand/brandname
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} hostname$ [NC]
RewriteCond %{HTTP_HOST} !index
RewriteRule ^(.*)\.html$ http://hostname/subdir1/subdir2/siterootdir/brands/index/brandsproduct/brand/$1 [R=302,L]把这个放在http://hostname/subdir1/subdir2/siterootdir/brands/的位置
\.html从URL中删除html扩展。
R=302将重定向标记为临时的。永久移动使用301。
https://stackoverflow.com/questions/30319389
复制相似问题