Mobile app version of vmapp.org
Login or Join
Lengel546

: Rewrite cond regex to split an url with a / I'm struggling to correct the aftereffects a bogus redirect I made which led to a lot of 404s. I need to 301 redirect URLs that look like

@Lengel546

Posted in: #301Redirect #ModRewrite

I'm struggling to correct the aftereffects a bogus redirect I made which led to a lot of 404s.
I need to 301 redirect URLs that look like


example.com/xysometext


to


example.com/xy/sometext


the example.com/xy and example.com/xy/ parts are permanent, while sometext is unique for each page (i.e. .*)

I'm only starting to undestand mod-rewrite syntax, help much appreciated. Thanks.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Lengel546

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

ok I figured it out


RewriteRule ^xy(.*)$ /xy/ [R=301,L]

10% popularity Vote Up Vote Down


 

@Becky754

Try this:

RewriteCond %{REQUEST_URI} !^/xy/ [NC]
RewriteCond %{REQUEST_URI} ^/xy(.*)$ [NC]
RewriteRule .* www.example.org/xy/%1.html [R=301,L]


I think should do it. Please let me know and I can update the answer.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme