0

Current working url of acticles is following:

http://domain.com/index.php/news/{CATEGORY_ID}/{ARTICLE_ID}-{slug}.html

but I need this url to work also (via htaccess 301 redirect)

http://domain.com/index.php/news/article/view/{CATEGORY_ID}/{ARTICLE_ID}/

Please help to implement this redirect with parameters. And this is the content of .htaccess file I have:

DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.(ico|js|gif|jpeg|jpg|png|css|swf|flv)$ index.php

Thanks

3 Answers 3

1

this should work:

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
2
  • Thanks for answer, but still it doesn't redirects and get this: Fatal error: Uncaught exception 'Zend_Controller_Router_Exception' with message 'No route matched the request' in Feb 21, 2013 at 18:49
  • Guess that URL causing mentioned error in the app log is in the final rewriten format (the original one)? When this aply, you should look at Zend framework routing configuration, maybe it is missing right -{slug} part of request. If not you can turn on RewriteLog and examine what exactly is going on while rewriting by adding two more directives like this to .htaccess: RewriteLog /path/to/logfile \newline RewriteLogLevel 3 . Loglevel 3 should be enough for analyzing this issue, of course you can raise the log level bit more, but it is then so verbose and thus unnoticed.
    – Kamik
    Feb 22, 2013 at 11:55
0
RewriteRule index.php/news/article/view/(.*)/(.*) index.php/news/$1/$2
0

Assuming that the category and article IDs are numerical:

RewriteRule /index\.php/news/article/view/(\d+)/(\d+)/$ /index.php/news/$1/$2.html

If the IDs aren't numerical those portions should be replaced with ([^/]+).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .