Reputation: 65
****** Already answered *******
I am currently trying to rewrite urls as follows:
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ article.php?title=$1 [NC,L]
This will take a url such as www.mydomain.com/lemons and rewrite to www.mydomain.com/article.php?title=lemons
That's all good and what I want.
The actual article on lemons is then pulled from a database and displayed at that url.
Within the article I then have some tags. For example, the lemons article might have the tags: fruit, yellow
The url for each tag would look like this:
www.example.com/tag/fruit
www.example.com/tag/yellow
I have added the following to my htaccess file:
RewriteRule ^tag/([A-Za-z0-9-]+)/?$ tag.php?tag=$1 [NC,L]
So, now when I click on the tag of fruit I am taken to: www.mydomain.com/tag/fruit
This will then pull a list of all articles from the database with the tag of fruit
Any urls within this page are displayed as http://www.example.com/tag/newarticle
e.g. http://www.example.com/tag/apple
However, I need http://www.example.com/apple
Many thanks
Upvotes: 0
Views: 21
Reputation: 65
I feel so stupid!
I just needed to add a / to the beginning of the article link.
Upvotes: 1