目前的工作url如下:
http://domain.com/index.php/news/{CATEGORY_ID}/{ARTICLE_ID}-{slug}.html
但我需要这个url也工作(通过htaccess的301redirect)
http://domain.com/index.php/news/article/view/{CATEGORY_ID}/{ARTICLE_ID}/
请帮助实现这个redirect与参数。 这是我拥有的.htaccess文件的内容:
DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule !\.(ico|js|gif|jpeg|jpg|png|css|swf|flv)$ index.php
谢谢
这应该工作:
DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} ^/index\.php/news/article/view/(.+)/(.+)$ RewriteRule .* /index.php/news/%1/%2-all-the-same.html [L,R=301,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule !\.(ico|js|gif|jpeg|jpg|png|css|swf|flv)$ index.php
RewriteRule index.php/news/article/view/(.*)/(.*) index.php/news/$1/$2
假设类别和商品ID是数字的:
RewriteRule /index\.php/news/article/view/(\d+)/(\d+)/$ /index.php/news/$1/$2.html
如果ID不是数字,则应该用([^/]+)replace这些部分。