Problem with url rewriting

Hi All,

I am trying to rewrite below url for one of my joomla pages.

For that I am using below code in htaccess

RewriteRule ^newsalert/([a-z_]+)/([a-z]+)/([0-9]+)/([0-9]+)$ index.php?option=$1&view=$2&id=$3&catid=$4

But when I am accessing the url http://xyz.com/newsalert/com_content/article/20651/1 then it’s showing me contents from index page only. What is wrong here?

Regards,
Nilanjan

neel,

RewriteEngine On
RewriteRule ^newsalert/([a-z_]+)/([a-z]+)/([0-9]+)/([0-9]+)$ index.php?option=$1&view=$2&id=$3&catid=$4 [L]

That’s fine. The Joomla content was because I was fooled by the first responder’s comment. If that’s your only mod_rewrite, there should be no problem.

Regards,

DK

nil,

First, you have no Last flag.

Second, you don’t show your whole mod_rewrite code so we have no idea of the order. If your code is before Joomla’s, then it’ll be altered by their code to display the index.php script. If not, then your code will likely never be executed.

Regards,

DK

neel,

Did you run the test in my signature tutorial to ensure that you have mod_rewrite enabled?

Regards,

DK

But surprisingly tht’s not working for me. I can see the contents from index page even though the title in internet explorer has changed.

Hi DK,

Thanks for your reply. Please check my entire mod_rewrite code below. Please note that I am rewriting the url only for one page.

RewriteEngine On
RewriteRule ^newsalert/([a-z_]+)/([a-z]+)/([0-9]+)/([0-9]+)$ index.php?option=$1&view=$2&id=$3&catid=$4 [L]

One more thing I could not understand what you meant to say by “If your code is before Joomla’s, then it’ll be altered by their code to display the index.php script. If not, then your code will likely never be executed.”

Joomla itself has a pretty good SEF (Search Engine Friendly) URLs for you. So why do you want to do that in your own way?

Firstly the default SEF management is pretty cool. For that to enable SEF:

  • Rename the htaccess.txt file to .htaccess (from command line if you are in windows)
  • Go to Administrator->Global Configuration.
  • In the Site tab, on the right hand side there is SEO Settings. Enable (click Yes) first two options and save.
  • Then go to site and see the links.

And there are other joomla extensions free to download here: