301 Redirect on older Joomla SEF URLS - .htaccess

I am working on removing an old Joomla 1.0 site that has the SEF module installed. I need to redirect the URLs to static pages in a search engine friendly way.
A typical URL looks like: www.mysite.com/index.php?/this-page.html.
I need to forward it to a static page on the same site like: www.mysite.com/this-page.html
So, I edited htaccess to read:
redirect 301 /index.php?/this-page.html http://www.mysite.com/this-page.html
The redirect does not seem to work. Any ideas? A wild card redirect to strip out the "/index.php?/" would be a bonus since I have to do about 80. I'm happy to do them manually, too.

try this below and let me know
redirect /index.php?/this-page.html http://www.mysite.com/this-page.html

Add in your .htaccess
Redirect /path/to/new/folder http://www.yoursite.com/new_page.html
The firs argument should be the path to the folder

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index.php/
RewriteRule ^index.php/(.*) /$1 [R,L]
This eliminates index.php from all old sef urls

Related

Redirect everything after domain.com/articles.php

So i have this issue, with changing an old site with a new and I need to redirect all the old links. So have this:
domain.com/articles.php?var=1
I basicly want to redirect everything after articles.php to just domain.com, including the /articles.php.
Thank you in advance.
Try adding this to your htaccess file:
RedirectMatch 301 ^/articles\.php$ /
or if you have mod_rewrite rules already in your htaccess file, you need to use mod_rewrite isntead, and add this rule above whatever rules are already there:
RewriteRule ^articles\.php$ / [L,R=301]

Drupal 301 redirects

I am doing a set of 301 redirects in Drupal.
I am using a standard method in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
</IfModule>
but the return url ends up with "?q=user" and stops it working. eg:
http://thesitedomain.com/about?q=user/about
I am not great at htaccess redirects (obviously) and I am no Drupal expert at all.
Also, if you know of a comprehensive htaccess rewrite resource I would much appreciate reading hat.
You will need to use mod_rewrite instead to strip out existing query string:
RewriteEngine On
RewriteRule ^user/testimonials/?$ http://thesitedomain.com/testimonials? [L,NC,R=301]
RewriteRule ^user/contact/?$ http://thesitedomain.com/contact? [L,NC,R=301]
Take note of trailing ? in target that strips out existing query string.
I can't speak to drupal, but I know you don't need to enclose those redirects in the <IfModule mod_rewrite.c> tags, since they don't use the RewriteEngine, the below would suffice:
Redirect 301 /user/testimonials http://thesitedomain.com/testimonials
Redirect 301 /user/contact http://thesitedomain.com/contact
Are both urls in the same drupal? Or are you moving from a different site?
I mean:
/user/testimonials
http://thesitedomain.com/testimonials
Maybe what you need is to add an url alias for /user/testimonials like /testimonials
See under admin at /admin/config/search/path in drupal 7.
Using .htaccess file is not a good practice, because, in some updates you have to update the .htaccess file too.
You can try GlobalRedirect module to manage your redirects.

redirect old links (HTML site) to a new page (PHP site)

Recently I built a site with php but the old site they had was all in HTML. So now I dont know what what is the best way to redirect all those old links to the new site (maybe redirect all links with HTML to the main domain) with .htaccess, what is the best practice ?
Here is what I have tried but the site says to many redirect loops:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.de
RewriteRule (.*) http://www.example.de/$1 [R=301,L]
RedirectMatch "\.html$" http://www.example.de
So first we redirect all non-www links to www, then when the page has .html in the end to redirect to the main site.
Option 1: Redirect all old .htmllink to new sites's /
RewriteEngine On
RewriteRule \.html$ / [L,R=301,NC]
Option 2: If .html file name and .php file names are same then redirect all old .htmllink to new sites's .php /
RewriteEngine On
RewriteRule ^(.+?)\.html$ /$1.php [L,R=301,NC]
Depends, if it is a new domain you need to point to, add a domain pointer from the old domain to point towards the new domain, this will resolve in the server handling the redirect, this is the most efficient way.
This will work better than .htaccess because it's faster and does not cause a second initial page load (due to redirect).
If you don't have access to the server or domainpointers you could make the index.html an index.php file if php runs on the old server, from here simply put:
header('Location: http://www.newdomain.com/');
This will automatically redirect.
Hope this helped you.
&dash; Sid

Joomla 3.0 - redirect 301 remove index.php add .html

I migrated an old joomla site to a Joomla 3.0. I changed the URLs into SEF friendly URLs and i need to redirect all old URLs (www.mysite.com/index.php/mypage) to the new one (www.mysite.com/mypage.html)
I tried to add this code at the bottom of my .htaccess but it doesn't work:
RewriteEngine on
RewriteRule ^/index.php/(.*)$ http://www.nextlog.it/$1 [R=301,L]
RewriteRule ^/index.php/(.*)$ $1.html [R=301,L]
You don't need the first rule, and if this is in your htaccess, remove the leading slash in your regex pattern:
RewriteEngine on
RewriteRule ^index.php/(.+)$ /$1.html [R=301,L]
I would use com_redirect which is built in and will do permanent redirects. Over time the search engines will update their indexes to go to the new pages, then you can delete the redirect pages ... but in the meantime monitor where direct links are coming from. THose you need to leave in place until the direct links are updated.

Problems with htaccess Redirect (Page on one domain to same page on another)

I'm trying to redirect a few pages to a new domain and I have done this before but for some reason I can't get the code to work.
RewriteEngine On
Redirect 301 http://domain.com/page1.html http://domain2.com/page1.html
Can anyone see where I'm going wrong?
In .htaccess file the below code will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Since you say you only want to direct a FEW of your pages and not all of them, you can do:
RewriteEngine On
Redirect /~myaccount/oldpage.html http://www.newsite.com/newpage.html
You specify the path to the page on your current server followed by the URL to redirect to.
OR you can do:
RedirectMatch 301 ^/oldpage\.html$ http://www.newsite.com/newpage.html

Resources