301 redirect phpbb2 to xenforo - .htaccess

Could someone please help me with my .htaccess settings? I need to redirect my old forum urls (phpbb2) to new xenforo urls.
Example
Old:
www.myforum.de/ftopic7469.html
New:
www.myforum.de/threads/werbelinks-hier-im-forum.7469/
Same with Forums:
Old:
www.myforum.de/forum61.html
New:
www.myforum.de/forums/wuensche-und-feedback.61/
Thanks for help!

Try the following:
RewriteEngine on
RewriteRule ^ftopic([0-9]+)\.html$ /threads/$1 [R,L]
RewriteRule ^forum([0-9]+)\.html$ /forums/$1 [R,L]
Note that it doesn't take care of slug, but, as per https://stackoverflow.com/questions/34473844/nginx-redirect-rewrite-vbulletin-urls-with-slug-to-xenforo-slug-optional/38166902#38166902, the slug part isn't actually mandatory, so, we don't have to worry about it.

Related

How to redirect multiple old urls to new urls using a 301 redirect via htaccess

I have recently change some URLs from my website to make it more SEO friendly. I have old urls that I would like to link to new urls. The old urls are no longer available but I would like the old urls to redirect to the new urls.
My current 301 redirect code below is for http:// to https://www, which I need.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [L,R=301,NC]
How do I make it so that I can also redirect from old urls to new urls as well. Is it possible with the 301 redirect?
Old url examples:
www.mywebsite.com/book-stories.html
www.mywebsite.com/book-journals.html
New url examples:
www.mywebsite.com/stories.html
www.mywebsite.com/journals.html
Any help would be much appreciated.
If you only have a handful, static redirections you can do it appending RewriteRules just as you are doing:
RewriteRule ^book-stories.html$ stories.html [R=301]
RewriteRule ^book-journals.html$ journals.html [R=301]
If they all have a fixed pattern, you could exploit that to reduce the amount of rules.
RewriteRule ^book-([a-z0-9.-]+).html$ $1.html [R=301]
If you have many different rules that you will be updating, you can look into indexed maps or even database-based RewriteMaps
I tried the above code and didn't work and to be honest I could have been doing it incorrectly. I did look into it further and tried another 301 redirect
Redirect 301 book-stories.html https://www.mywebsite.com/stories.html
Redirect 301 book-journals.html https://www.mywebsite.com/journals.html
That worked for me. Hope this helps anyone else who will encounter this issue.

Replace part of a URL with .htaccess

I had to change the name of a subpage and now the problem is that all shared links on Facebook, Twitter, etc. are not working anymore.
That's why I am trying to redirect only a part of a URL with .htaccess but I have no solution yet.
It should work like this:
www.mydomain.com/feeds/details/ --> www.mydomain.com/highlights/details/
I hope you can help me!
It will depend on your server but you are looking for something along these lines
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 /feeds(.*) /highlights/$1
You can try rewriting the URL using RewriteRule, like follows:
.htaccess
RewriteEngine on
RewriteRule ^/feeds/details$ /highlights/details/
Hope, that works for you.
You can find more information here.
I took your tip and adjusted my reality.
My problem:
https://example.com/contact/example.com
My solution:
RedirectMatch 301 (.*)/example.com(.*) $1/$2
After solution, redirect:
https://example.com/contact/

301 redirect based on text to new url

I'm having a little problem with an URL. I hope you can help me out!
I have this url:
http://www.domain.com/search.html?page=shop.product_details&flypage=vmj_softy.tpl&product_id=1408&category_id=1028
This needs to be redirected to:
http://www.domain.com/search.html?page=shop.product_details&flypage=vmj_color_plus.tpl&product_id=1408&category_id=1028
The only thing that needs to be changed is the flypage=vmj_softy to flypage=vmj_color_plus
The product ID and Category ID has to be a string (at has to change on all products)
I Think I need to use apaches mod_rewrite for this, but i've tried everything but I'm not able to get this to work!
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=shop.product_details&flypage=vmj_softy.tpl(.*)$
RewriteRule ^/?search.html$ /search.html?page=shop.product_details&flypage=vmj_color_plus.tpl%1 [L,R=301]

How to redirect users to new url on same site with .htaccess?

I recently changed URLs of my site.
Old URL: mysite.com/top/1
New URL: mysite.com/top/page=1
When the users visit old url I want to redirect them to new url. How can I do it with .htaccess?
i have this rewrite rule for new url
RewriteRule ([top,new]+)/page=([0-9]+) index.php?h=$1&page=$2 [L]
Try this
RewriteEngine On
RewriteRule ^top/([0-9]+)$ top/page=$1 [R=301,L]
For your original question, you should try something like this:
RewriteRule ^top/([0-9]+)$ top/page=$1
But according to your comment on Virendra's post, this will probably better suite your needs:
RewriteRule ^(top|new)/([0-9]+)$ index.php?h=$1&page=$2 [R=301,L]
This will match both top and new, and rewrite only if a valid page number is specified.
Hope this helps

Simply remove a url segment with .htaccess

I am simply trying to get this URL:
http://foo.com/entry/random-entry-123
to redirect to:
http://foo.com/random-entry-123
The "random-entry-123" is dynamic. Different for each entry.
Any help with this is greatly appreciated!
Assuming no further rewrites are in use, and all links inside /entry/ are to rewritten, then try this:
RewriteEngine on
RewriteBase /
RewriteRule ^/entry/(.+)$ /$1 [L,QSA]
Lose the [L] if there are further rewrites ahead in the file.
Although this has already been answered, it didn't work for me when I had two segments after the first, eg:
http://foo.com/entry/random-segment/random-entry-123
Instead this worked for me and also takes care of 301 redirects:
RedirectMatch 301 /entry/(.*) /$1
Hope this helps.

Resources