i am trying to redirect thoses urls ( from a phphbb )
http://www.example.com/fraiseuses/restauration-gambin-10n-t33924-45.html
http://www.example.com/fraiseuses/une-gambin-10n-plus-sur-forum-t34642.html#p675680
to a the correct xenforo url
http://www.example.com/threads/restauration-gambin-10n.33924/page-3
http://www.example.com/threads/34642/page-1#post-675680
my htacces
RewriteEngine On
RewriteRule ^post([0-9]+).html$ /posts/$1 [R=301,L]
RewriteRule ^.*-f([0-9]+)$ /forums/$1 [R=301,L]
RewriteRule ^[^/]+/topic([0-9]+).html /threads/$1 [R=301,L]
RewriteRule ^.*-t([0-9]+).html /threads/$1 [R=301,L]
RewriteRule ^[^/]+/[^\./]+-t([0-9]+)-15\.html$ /threads/$1/page-1 [R=301,L]
RewriteRule ^[^/]+/[^\./]+-t([0-9]+)-30\.html$ /threads/$1/page-2 [R=301,L]
RewriteRule ^[^/]+/[^\./]+-t([0-9]+)-45\.html$ /threads/$1/page-3 [R=301,L]
Unfortunately i can't find my mistake, can somebody point out my mistake please? Thanks.
There are no phpBB-specific redirect scripts, but these will work::
http://xenforo.com/community/threads/redirection-scripts-for-vbulletin-3-x.5030/
The basic function of these scripts is to map the old ids to the new ones. They can work with phpBB URLs given appropriate rewrite rules. Here are steps for you:
1) Upload these redirect scripts to your old forum location (the /forum folder):
http://xenforo.com/community/threads/redirection-scripts-for-vbulletin-3-x.5030/
You only need the 301config.php file and the showthread.php file to redirect threads (which are the most important thing).
2) Edit the 301config.php file. Uncomment this line (remove the //) and specify the path to your XF directory:
// $fileDir = '/home/username/www/forums';
You may also need to specify the name of the import log table if it's not the default (xf_import_log). It may be named archived_import_log:
// define('IMPORT_LOG_TABLE', 'import_log_x');
3) Add these rewrite rules to your .htaccess file in the /forum directory. This is based on previous phpBB imports. I assume your URLs follow the same format:
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$)
RewriteRule ^viewtopic\.php$ /forum/showthread.php?t=%2 [L,R=301,NC]
thx
i did this :
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
RewriteRule ^viewtopic\.php$ /threads/%2? [L,R=301,NC]
RewriteCond %{QUERY_STRING} (^|&)p=([0-9]+)(&|$) [NC]
RewriteRule ^viewtopic\.php$ /posts/%2? [L,R=301,NC]
RewriteCond %{QUERY_STRING} f=(\d+)$ [NC]
RewriteRule ^viewforum\.php$ /forums/%1 [L,R=301,NC]
RewriteRule ^viewforum\.php$ /forums/%1? [L,R=301,NC]
Related
I am trying to redirect all URLs on my site (let's call it www.site1.com) except one in my .htaccess file. I currently have the following in my .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/my/page$ [NC]
RewriteRule (.*) https://www.site2.com [R=302,L]
With the above, all requests to www.site1.com are redirected to www.site2.com, including the one that I do not want to redirect.
After some experimentation, I have found that the following works to redirect only a specific page:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/my/page$ [NC]
RewriteRule (.*) https://www.site2.com [R=302,L]
I'm not sure why the ! operator isn't working as I expect. Perhaps there is an error in my regex?
Some additional bit of information. This is a Drupal site running on a dedicated cPanel host. But I have been sure to put this new redirect rewrite rule before all the other Drupal-specific rewrite rules.
Any help would be greatly appreciated.
RewriteCond %{REQUEST_URI} !/(index.php) [NC]
RewriteRule ^(.*)$ index.php [NC,QSA,L,END]
You need to make sure you exclude the page you redirect to from you list of possible url that get redirected(to avoid the loop) and then you can add more before the RewriteRule.
RewriteCond %{REQUEST_URI} !/(index.php) [NC]
RewriteCond %{REQUEST_URI} !/(index_new.php) [NC]
RewriteRule ^(.*)$ index.php [NC,QSA,L,END]
I have a Forum on my site and need to redirect weirdly generated urls.
Every url contains ?id=, eg:
https://www.example.com/forum/topic/casualthread/page/25?id=casualthread
and I need to remove the ?id= and everything that follows in order to have:
https://www.example.com/forum/topic/casualthread/page/25
I am trying to modify this code I found here on Stackoverflow with very scarce results:
RewriteEngine On
RewriteBase /
# Make sure there is a query string
RewriteCond %{QUERY_STRING} .
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /?id= [R=301,L]
The htaccess file i am editing is in the forum directory:
https://www.example.com/forum/
and it redirects everything to the homepage https://www.example.com: what am I doing wrong?
You can use this
RewriteEngine on
RewriteCond %{QUERY_STRING} id=
RewriteRule ^ %{REQUEST_URI}? [L,R]
Since not just id, but also some other parameter(s) may be present in the query string, use:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)(^id=[^&]*&?|&id=[^&]*)(.*)$
RewriteRule ^(.+) /$1?%1%3 [R=301,L]
I all, I've been searching a lot but I don't find an answer to my problem.
I have already made a .htaccess file that redirects all the different pages and files on my old domain (www.olddomain.com) to my new domain (www.newdomain/blog.com). I'm moving a blog to an e-commerce, that's why 301 to www.newdomain/blog.com.
However, I need to use the Change of Address Tool (Google Webmaster Tools) but I can't because www.olddomain.com must redirect to www.newdomain.com and now it is redirecting to www.newdomain/blog.com and Google don't let me change the address.
My .htaccess is working fine except for that, here it is
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ http:/www.newdomain.com/blog/$1 [R=301,L]
BUT, I have not found any way to make an exception to redirect just www.olddomain.com must ---> www.newdomain.com
I have tried to make that exception in the following way:
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule ^/$ http://www.newdomain.com/ [R=301,L]
RewriteRule (.*)$ http://www.newdomain.com/blog/$1 [R=301,L]
But nothing has worked...
Please, can you help me?
Thanks in advance
Try :
RewriteEngine On
#redirect http://oldsite.com/ to http://newsite.com
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$
RewriteRule ^$ http:/www.newdomain.com/$1 [R=301,L]
#redirect http://oldsite.com/pages to http://newsite.com/blog/pages
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$
RewriteRule ^(.+)$ http:/www.newdomain.com/blog/$1 [R=301,L]
Note the ^$ in pattern it matches / ie : http://example.com/ or the directory the htaccess file is in.
Clear your browser cache before testing this.
I need to redirect from this URL:
www.devsite.com/level1/page1.html?brand=6
to:
www.productionsite.com/level1/page1.html?brand=6
I've come across various redirect w/ parameters answers here on stack, but none that specifically address how to rewrite part of .htaccess to redirect to a totally different domain. Help!
Just do a redirect from devsite to productionsite. Second line appends after the devsite domain to the new location.
RewriteCond %{HTTP_HOST} !^www.devsite.com$ [NC]
RewriteRule ^(.*)$ http://www.productionsite.com/$1 [L,R=301]
Add this to the htaccess file in the document root of your www.devsite.com domain. Add it above any other rules that may already be in that file.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?devsite\.com$ [NC]
RewriteRule ^level1/page1\.html$ http://www.productionsite.com/level1/page1.html [L,QSA]
RewriteCond %{QUERY_STRING} \?brand=6
RewriteCond %{HTTP_HOST} ^www\.devsite\.com$
RewriteCond %{SERVER_PORT}s ^(443(s)|\d+s)$
RewriteRule ^level1/page1\.html$ http%2://www.productionsite.com/$0 [R=301,QSA,L]
To note, I've found similar questions on StackOverflow but they have not worked as I need.
I have a URL such as:
http://www.example.com/index.php/test
I'd like to remove the index.php directory, so if the above is entered it would go to:
http://www.example.com/test
This appears to work
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
However if the url is:
http://www.example.com/index.php?option=example
It turns into
http://www.example.com/?option=example
So index.php should only be removed if it's a directory like in my first example.
Also if you type in for instance:
http://www.test.example.com/index.php/index.php/dfd
It should go to
http://www.test.example.com/dfd
the rules below will:
not apply for /index.php?o=a
redirect /index.php/index.php/dfd to /dfd
redirect /index.php/index.php/dfd?a=b to /dfd?a=b
redirect /index.php/index.php?a=b to /index.php?a=b
.
RewriteCond %{QUERY_STRING} .+
RewriteRule ^index\.php(/index\.php)+/?$ /index.php [R=302,L,QSA,NC]
RewriteCond %{QUERY_STRING} ^$ [OR]
RewriteCond %{REQUEST_URI} !index\.php/?$
RewriteRule ((^|/)index\.php)+/?(.*)$ /$3 [R=302,L,QSA,NC]