Kuubs
Kuubs

Reputation: 1340

Add subdirectory to url in htaccess

I'm trying to add a subdirectory to my URL. So for example, my /news must go to /blog/news including all their articles

I came up with this:

RewriteCond %{REQUEST_URI} !^/news/.*$
RewriteRule ^(.*)$ /blog/news/$1 [R,L]

See below for fix!

Upvotes: 0

Views: 1359

Answers (1)

Kuubs
Kuubs

Reputation: 1340

I fixed it with the following rule:

RewriteRule ^news/(.*)$ /blog/news/$1 [R=301,NC,L]

Make sure to clear your cache when testing and to set R=302 as that will make it a temporary redirect. Set it back to R=301 once you know it is working.

Upvotes: 1

Related Questions