RewriteRule ^/wis/9-3/1998/(.*)$ /9400/wis/9-3/1998/$1 [L]
This won't work in a directory (or .htaccess
) context because of the slash prefix on the RewriteRule
pattern. In .htaccess
only a partial URL-path is matched, which notably does not start with a slash. So, this should be written:
RewriteRule ^wis/9-3/1998/(.*) /9400/wis/9-3/1998/$1 [L]
(The end $
is superfluous since regex is greedy by default.)
Note also that this is an internal rewrite, not an external "redirect", as you've stated in your question. (Although an internal rewrite might well be what you require?)
Note also, @dan's comment above. Generally, the regex should be as specific as possible.
You could also "simplify" the above directive to save repetition:
RewriteRule ^(wis/9-3/1998/.*) /9400/$1 [L]
UPDATE#1: Within my htaccess I have some default wordpress expressions
If this is WordPress the you can't perform this type of internal rewrite in .htaccess
- because of the way WordPress routes the URLs (it looks at the requested URL, to the rewritten URL).
However, you can use an external redirect (ie. the URL changes). In which, case this should go at the top of your .htaccess
file, before the WordPress front-controller:
RewriteRule ^(wis/9-3/1998/.*) /9400/$1 [R,L]
Note the addition of the R
flag. (This is a temporary 302 redirect.)
UPDATE#2: is there a way to include a range where 1998 is located. Let's say from 1998 to 2005
Regex is not very good for doing "ranges", however, since you have a fairly limited range you can use alternation and include each possible value: 1998, 1999, 2000, etc.:
RewriteRule ^(wis/9-3/(?:1998|1999|2000|2001|2003|2003|2004|2005)/.*) /9400/$1 [R,L]
/0.general changes
<- Is this a subdirectory or file, and does the format for the name remain consistent (e.g., a digit followed by a period and then a word)?