I'm gradually restructuring my site's URLs.
I have a group of old URLs with patterns like this:
mt-14_21-28
mt-15_26-hasta-16_04a
mc-01_21-28
lc-07_36-50-y-lc-08_01-03
lc-09_28-36
lc-22_14-71-y-23_01-56
jn-18_01-hasta-19_42
... there are other patterns
The idea is to create a redirect that does the following:
- Determine if the URL starts with
mt-,mc-,lc-, orjn- - If so, change all
_in that URL to-and also add thebibla/evangelios/prefix. - Alternatively, for
mt-, addsan-mateo, formc-, addsan-marcos, forlc-, addsan-lucas, and forjn-, addsan-juan.
For example:
biblia/evangelios/san-mateo/mt-14-21-28
biblia/evangelios/san-mateo/mt-15-26-hasta-16-04a
biblia/evangelios/san-marcos/mc-01-21-28
biblia/evangelios/san-lucas/lc-07-36-50-y-lc-08-01-03
biblia/evangelios/san-lucas/lc-09-28-36
biblia/evangelios/san-lucas/lc-22-14-71-y-23-01-56
biblia/evangelios/san-juan/jn-18-01-hasta-19-42
I've tried this, but it doesn't work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(jn|mt|mc|lc)-([a-z0-9-]*)_{1}([a-z0-9_.-]*)$ /$1-$2-$3 [N]
RewriteRule ^jn-(.*)$ /biblia/evangelios/san-juan/jn-$1 [R=301,L]
RewriteRule ^mt-(.*)$ /biblia/evangelios/san-mateo/mt-$1 [R=301,L]
RewriteRule ^mc-(.*)$ /biblia/evangelios/san-marcos/mc-$1 [R=301,L]
RewriteRule ^lc-(.*)$ /biblia/evangelios/san-lucas/lc-$1 [R=301,L]
</IfModule>
Is there a way to do this via .htaccess, considering I don't have administrator access to that server?
<IfModule>wrapper. What version of Apache (or LiteSpeed??) are you on?.htaccessfile and where in relation to the existing directives have you placed the above code? (And make sure all caches are cleared before testing.)<IfModule>and used302, but it doesn't work, it dos nothing. I can't see the Apache version, thehttpd -vcommand doesn't work (shared hosting) ..htaccessthe redirection occurs, however, the replacement of the_with-is not done. For example, I get:biblia/evangelios/san-mateo/mt-14_21-28instead ofbiblia/evangelios/san-mateo/mt-14-21-28.