Some of my article pages are linking to a menu items that uses aliases as the page url. For example: mysite.com/realurl. However these articles can still be accessed via the browser using mysite.com/?option=com_content&view=article&id=xx, where xx is the article id.
What is the best and easiest way to redirect/rewrite all these urls to the menu item alias, seo friendly, urls?
the standard way to rewrite urls is to use the joomla router function:
echo JRoute::_('index.php?option=com_content&view=article&id=xx');
This calls the router.php - file for the component in question (here com_content/router.php)
regards Jonas
This should achieve what you are looking for
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /\?option=com_content&view=article&id=(.*)\ HTTP
RewriteRule ^ /%2\? [R=302,L]
RewriteRule ^([0-9]+) /?option=com_content&view=article&id=$1 [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.