Reputation: 23
I’d like to redirect the content of a section of a website without redirecting the landing page of this section.
Its a wordpress site by the way and we are talking about moving the categories that were under this «directory».
Here’s a exemple of the categories and the redirect :
/articles-bebe/alimentation-bebe/ --> /cat/articles-bebe/alimentation-bebe/
Here is what I did so I don’t have to create 1 000 redirect for each categories.
RewriteEngine On
RewriteBase /
RewriteRule ^articles-bebe/(.*)$ /cat/articles-bebe/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
All the redirect works great for all the pages inside the section, however the « articles-bebe » has landing page that I don’t want to redirect to the new section /cat/...
So this needs to stay as is :
/articles-bebe/ -> /articles-bebe/
When right now its getting redirected to :
/articles-bebe/ -> /cat/articles-bebe/
Is there a way to add an exception to the RewriteRule that I added so the 2 pages do no get redirected to the new section ?
Upvotes: 2
Views: 32
Reputation: 785276
Just change your regex to use .+
instead of .*
:
RewriteRule ^(articles-bebe/.+)$ /cat/$1 [R=301,L]
Upvotes: 1