multiple 301 redirects htaccess - .htaccess

I recently changed the filename of some of my pages. For example
work1.html to acn-website.html
work2.html to inkdrawn-website.html
etc.
I currently have the following in my htaccess file;
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^fullfatdesigns\.co.uk$
RewriteRule (.*) http://www.fullfatdesigns.co.uk/$1 [R=301,L]
ErrorDocument 404 /error/404.php
ErrorDocument 403 /error/403.php
How do I go about inserting multiple 301 re-directs into my existing file?
Thank you
Wayne

You could add
RewriteRule oldPage\.html http://www.fullfatdesigns.co.uk/newPage.html [R=301,L]
after RewriteEngine on for every redirect.

Related

.htaccess 301 redirect after trailing slash

I know this has been asked so many times before but I coulnd't find this particular script.
So I've started a franchise, and I've moved my www.site.com to shop1.site.com (shop2.site.com also exists.)
Google seems confused by the new setup so this is what I need
If someone goes to a url containing a directory after the trailing slash, I need to redirected to the new site with a 301
If not, leave it be
For example:
www.site.com/info/ -> shop1.site.com/info/
www.site.com/help/ -> shop1.site.com/help/
www.site.com (leave as is)
So basically any url with a directory, redirect, otherwise leave it be
Update
here is my current htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ErrorDocument 404 /index.php
ErrorDocument 500 /index.php
This is what I needed. This redirects every page except for the root. Be warned, this also redirect's all traffic to HTTP and not HTTPS
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#Rewrite everything except root
RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteRule ^.+$ http://shop1.site.com%{REQUEST_URI} [L,R=301]

htaccess 301 redirect to index page

I need the sloution for home page 301 redirection.
If I enter http://www.starmed.dk/index.php in the browse bar, then it will be redirected to http://www.starmed.dk without index.php
Any idea how to do this with an HTACCESS 301 redirect?
Thanks in advance.
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^starmed.dk[nc]
RewriteRule ^(.*)$ http://www.starmed.dk/$1 [r=301,nc]
//301 Redirect Old File
Redirect 301 www.starmed.dk/index.php www.starmed.dk
Edit:
Perhaps your configuration is different. perhaps this:
RewriteRule ^www.starmed.dk/index.php$ www.starmed.dk/ [R=301]
Try the following :
DirectoryIndexRedirect Off
RewriteEngine on
RewriteRule ^index\.php$ / [L,R]

Redirect 301 dynamic-URL to 404 error-page with htaccess?

Can someone help me to get the correct .htaccess rules for:
Redirect this specific ID url:
http://www.domain.com/watch.php?id=00000000001
to my 404 error page:
http://www.domain.com/404/
Use this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=00000000001$ [NC]
RewriteRule ^watch\.php$ /404/? [NC,L,R=301]

Domain name within domain name. How to redirect through htaccess

The crawling properties of site showing
http://www.abc.com/http://www.abc.com/index.php?option=com_toys
http://www.abc.com/http://www.abc.com/index.php?option=com_article
http://www.abc.com/http://www.abc.com/index.php?option=com_play&view=category&vid=10
The site been crawled like this, with errors coming in as duplicate url. Correct url is
http://www.abc.com/index.php?option=com_toys
http://www.abc.com/index.php?option=com_article
http://www.abc.com/index.php?option=com_play&view=category&vid=10
is there any way to 301 redirect
i tried using
RewriteCond %{REQUEST_URI} ^.*/http://www.abc.com.*$
RewriteRule .* index.php [R=301,L]
But its not achieving the desired as redirecting to http://www.abc.com/index.php
How to redirect through htaccess from incorrect url to correct url sttructure off site
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+http://.+?(/index\.php\?[^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]
Try this code :
RewriteEngine On
RewriteRule ^http://www.abc.com/index.php /index.php [QSA, R=301]

Redirect duplicate urls in htaccess

I have a big list of duplicate urls and i need to do some redirect
Example
www.mysite.com/mypage/name2_68.html
www.mysite.com/jjj/name2_68.html
www.mysite.com/aa/name2_68.html
www.mysite.com/5654/name2_68.html
www.mysite.com/mypage/myname87.html
www.mysite.com/6584/myname87.html
www.mysite.com/any-number/myname87.html
www.mysite.com/any_word/myname87.html
All i need to do is to redirect them to
www.mysite.com/mypage/myname87.html
www.mysite.com/mypage/name2_68.html
So all url with
www.mysite.com/anycharactere/example1.html
Will be redirect to
www.mysite.com/mypage/example1.html
This should work.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/mypage/?
RewriteRule ^[^/]+/(.*\.html?)$ /mypage/$1 [R=301,L]
Put it in your .htaccess
RewriteEngine On
RewriteRule .*/([^/]+.html)$ /mypage/$1

Resources