MyBB Community Forums

Full Version: 301 redirect from old to new rewrited URLs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

Recently I have turned on the option to use rewrited URLs, so I updated my .htaccess. Now I can access the pages using the new URL which finnishes with .html.

The problem is I want to create a 301 redirect using .htaccess to the new rewrited URLs, so if an user goes to showthread.php?tid=1 it's redirected to thread-1.html by default and with 301 code.

I tried it but didn't work with the standard 301 code.

Help would be very appreciated.

Kind regards from Spain.
You can install my Google SEO plugin and enable the Google SEO Redirect option. You don't have to enable any of the other features if you don't need them.
Thanks for your response. But I have a question. Does that redirection only work for Google? I'd prefer it to work with every search engine and with users, but the name ("Google" SEO Redirect) is maybe a bit confusing Wink
It's nothing specific to Google, it's standard HTTP 301 redirects that are followed not only by Google but by any browser.

It's called Google SEO because it's based on Google webmaster guidelines and Google documents such as "Google's SEO starter guide", which is basically a collection of do's and don'ts - and redirects like you described just happen to be one of the features implemented in this plugin.
Ok, good Smile can you link to the plugin, please? Maybe I'm giving it a chance, but the best solution for me would be to modify the .htaccess, something I will do as soon as I find the way to get 301 working. However thanks for your response.
http://mods.mybboard.net/view/google-seo

Doing it in the .htaccess isn't easy, since mod_rewrite was made for the other direction only.

Here's an example for a single rewrite:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/page\.php$
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^(.*)$ http://mydomain.site/page/%1.pdf [R=302,L]

You can adapt that for MyBB, but the rules will have to be more complicated, since query string parameters can be in any order, and you'd have to find a way to do it for every static rewrite rule... I daresay you'd have to write several hundred lines of redirect rules for a proper solution like this.

Maybe there's a better way, but I don't know of one.