I have several categories post:
General
News
Comedy
Competitions
Culture
Gaming
Food
etc
The posts url are in the following format:
www.mydomain/category-name/post-title
Example:
www.mydomain/food/how-to-make-paella
www.mydomain/gaming/game-of-theday
But I would like to hide from the URL the category name 'general' so for example.
instead of
www.mydomain/general/how-to-learn-spanish
have
www.mydomain/how-to-learn-spanish
I have tried some wiring a rewrite rule in the .htaccess but doesn't work.
Any idea how can I do it?
Thanks!
I have several categories post:
General
News
Comedy
Competitions
Culture
Gaming
Food
etc
The posts url are in the following format:
www.mydomain.com/category-name/post-title
Example:
www.mydomain.com/food/how-to-make-paella
www.mydomain.com/gaming/game-of-theday
But I would like to hide from the URL the category name 'general' so for example.
instead of
www.mydomain.com/general/how-to-learn-spanish
have
www.mydomain.com/how-to-learn-spanish
I have tried some wiring a rewrite rule in the .htaccess but doesn't work.
Any idea how can I do it?
Thanks!
You can use post name in your permalinks setting. And for Category Base and Tag Base make it blank
Hope this will help
Have you tried following Rewrite rule in your .htaccess ?
RewriteRule ^category/(.+)$ http://YOUR_SITE_NAME/$1 [R=301,L]
To achieve the desired URL structure where the category name is hidden for the "General" category, you can use the following .htaccess
rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Exclude the 'general' category from the URL
RewriteCond %{REQUEST_URI} !^/general/
# Rewrite the URL for posts in other categories
RewriteRule ^([^/]+)/([^/]+)$ /$1/$2 [L]
# Rewrite the URL for posts in the 'general' category
RewriteRule ^([^/]+)$ /general/$1 [L]
</IfModule>