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
Related
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]
I am trying to redirect the following (respectively):
http://sub.firstdomain.com/d/(all_files_and_folders)
http://sub.firstdomain.com/d2/(all_files_and_folders)
to
http://sub.seconddomain.com/d/(all_files_and_folders)
http://sub.seconddomain.com/d2/(all_files_and_folders)
There are other files and folders under the first subdomain that I do not want redirected. Previously this was working but now it seems like Go Daddy changed something and what I had is no longer working. Here it is:
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^stats/(.+) /dstats/count.php?statspage=$1 [L,NC,QSA]
RewriteRule ^(.+)\.deb$ /dstats/count.php?file=$1.deb [L,NC,QSA]
RewriteCond %{HTTP_HOST} ^sub\.
RewriteRule ^(d2?)/(.*)$ http://sub.seconddomain.com/$1/$2 [L,R=301]
You can ignore the RewriteRule. It is working fine. I wanted to make sure I included the entire .htaccess file just in case. My issue is with RewriteCond it seems.
The following should work:
RewriteEngine On
Redirect 301 /d/ http://sub.seconddomain.com/d/
Redirect 301 /d2/ http://sub.seconddomain.com/d2/
The above should only redirect anything in the /d/ and /d2/ folder of the sub subdomain.
EDIT: Second try
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub1\.
RewriteRule ^(d2?)/(.*)$ http://sub2.mydomain.com/$1/$2 [L,R=301]
I am trying to permanently redirect a url but it doesn't seem to work, this is what I have in the .htaccess file
RewriteEngine on
rewriteRule ^modules\.php?name=My_Page$ http://mysite.net/mypage [R=permanent,L]
As you can see I want to redirect modules.php?name=My_Page to http://mysite.net/mypage
I appreciate any help. Thanks
The path used in RewriteRule doesn't contain the querystring. Use
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^name=My_Page$
rewriteRule ^modules\.php$ /mypage? [R=permanent,L]
I am finding some problems in the htaccess of CMS with a 301 redirect.
When trying to solve canonical urls (redirecting site to www.site) I got the problem that I cannot log in in the back end (www.site/admin).
The htaccess condition is:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.site\.co.uk$
RewriteRule (.*) http://www.site.co.uk$1 [R=301,L]
I guess I need to include a expression that allows the URI /admin not to be redirected, but how?
Like this, for example:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !=www.example.co.uk
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule .* http://www.example.co.uk%{REQUEST_URI} [R=301,L]
i want to create with htaccess that if you go to www.website1.com/page.php that you go to www.website2.com/page.php, and www.website1.com/foo/bar/index.php to www.website2.com/foo/bar/index.php redirects. How can i do that with htaccess? Example please.
If mod_rewrite is available, you can put this code into the .htaccess of www.website1.com:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?website1\.com$
RewriteRule ^(.*)$ http://www.website2.com/$1 [L,QSA,R=301]
This would redirect every page on website1.com to the equivalent on website2.com