Mobile app version of vmapp.org
Login or Join

Login to follow query

More posts by @Speyer207

3 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

This is a rather more general solution, so in that respect it might not be what you are after, but it should redirect the URLs in your question.

RewriteEngine on
RewriteRule ^(d).(html|asp)$ /dir/.html [R=301,L]
RewriteRule ^(d)_([a-z]).html$ /dir/sub/-.html [R=301,L]


The first RewriteRule will match any single digit URL eg. "1.html" or "7.asp" and redirect to "/dir/1.html" or "/dir/7.html" respectively. The matches the first parenthesised sub pattern in the pattern that is matched.

The second RewriteRule matches a URL that contains a single digit followed by an underscore and then a single lowercase letter. The underscore is replaced with a hyphen in the redirect. eg. "6_g.html" is redirected to "/dir/sub/6-g.html".

10% popularity Vote Up Vote Down


 

@Nimeshi995

this is what i came up with

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^((1|2).html|(3|4).asp)$ /dir/.html [R=301,L]
RewriteRule ^(4_([a-b])).html$ /dir/sub/.html [R=301,L]
</IfModule>

10% popularity Vote Up Vote Down


 

@Tiffany637

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^1.html$ "http://example.com/dir/1.html" [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^1_a.html$ "http://example.com/dir/sub/1-a.html" [R=301,L]

RewriteOptions inherit


That should work

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme