简体   繁体   English

使用.htaccess文件将原始URL更改为漂亮URL

[英]change original URL to pretty URL with .htaccess file

I am trying to create pretty URL from my site, but I still newbie in .htaccess , I am so confuse to do it. 我正在尝试从我的网站创建漂亮的URL,但是我仍然是.htaccess的新手,我很困惑。

Original URL: 原始网址:

1. mysite.com/index.php?mode=frontend&act=viewArtikel&cat=hotnews&year=2017&month=02&link=hello-world

2. mysite.com/index.php?mode=frontend&act=viewProduct&cat=food&link=pizza

Expected: 预期:

1. mysite.com/hotnews/2017/02/hello-world.html
2. mysite.com/food/pizza.html

How to do it? 怎么做? Thanks in advance ps: please don't mark this post duplicate, sorry for my bad English 预先感谢ps:请不要将此帖子标记为重复,对不起我的英语不好

Try below rule, 尝试以下规则,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([\w-]+)/([\d]{4}+)/([\d]{2}+)/([\w-]+)\.html$ index.php?mode=frontend&act=viewArtikel&cat=$1&year=$2&month=$3&link=$4 [L]
RewriteRule ^([\w-]+)/([\w-]+)\.html$ index.php?mode=frontend&act=viewProduct&cat=$1&link=$2 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM