0
votes

I have a question relating to re-writing URL's using the .htaccess file.

I don't really understand the symbols and syntax for writing what I require for the htaccess file so I would really appreciate any help please.

SYSTEM INFORMATION Joomla 2.5.9 website I use K2 2.6.2 for creating my content When I create content for my blog using K2 I complete the 'Title alias (URL)'

HTACCESS QUERY As an example I have written an article called Top 10 Joomla Extensions The title alias URL is: top-10-joomla-extensions

When I view the article at the front end the URL is: http://www.pixelfire.com.au/website-and-graphic-design-blog/item/121-top-10-joomla-extensions

I would like to clean up this URL by removing: item/121- I have many other item URL's with different ID numbers I'd like to remove too. So the code I require needs to remove the ID number for every item in my Blog.

Each blog item URL has the words item/item ID number. Example item/121- Ideally I would like to remove the word item and the item number with the dash.

Hopefully someone can help me write the .htaccess code to achieve this and explain to me how it works.

Thank you very much in advance. Neil.

2

2 Answers

0
votes

You want to install a sef component such as sh404sef or joomsef which overrides joomla´s default router and gives you more configuration options

0
votes
RewriteEngine On
RewriteRule ^(.*)item/(\d+\-)?(.*) /$1$3 [R=301,L]

RewriteRule works as follows: Anything after "RewriteRule" and before the Space is our rule, Anything after said Space, is what to do

so: RewriteEngine On turn on the engine

RewriteRule tells apache, to start the magic. The rest is a regex declaration.

^ - start at begining of the string (.*) - get anything you desire and place it into variable $1 item/(\d\-)? - make sure the string item/ followed by digits and dash exists, but doesn't have to. Make sure it occupies the $2 variable. The questionmark says "might be there, but doesn't have to". (.*) - get anything that follows, and store it inside the variable $3

Then you say, redirect into: $1$3 which concatinates the strings stored in variables $1 and $3 (skipping item/887878-)

Finally the brackets. R=301 means, rewirte with 301 header And L says: this is the last thing you need to do. Stop here and reload.