I have updated my website and now i have a new URL structure. My old structure was like: subdomain.domain.com. My new structure is like: www.domain.com/folder/subdomain
I already added a subdomain wildcard to my dns (*.domain.com) and was hoping for a htaccess rule to redirect my old urls to my new urls.
(how) can this be done?
Thanks.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+).domain\.com$
RewriteRule ^ /folder/%1%{REQUEST_URI} [L]
Try putting this code in the htaccess file.
Related
I need to 301 redirect in .htaccess from old site with folder structure to new page that uses the ending folder name as a url param.
like this:
http://example.com/artists/artist-name
to
http://example.com/search-works.php?searchArtist=artist-name
a couple options:
RewriteRule ^artists/artist-name$ /search-works.php?searchArtist=artist-name [R=301,NC,L]
or
RewriteRule ^artists/(.*)$ /search-works.php?searchArtist=$1 [R=301,NC,L]
I am moving a Magento site from example.com/shopping to example.com and I have to 301 redirect all of the URLs to the new location (example.com). I am assuming I can use mod_rewrite in the .htaccess file to create a rewrite rule to do this? I tried to learn how to use mod_rewrite, but the syntax is so complex for me.
There are hundreds of pages that need to be redirected. Example:
http://www.example.com/shopping/product-category-1/product-sub-category.html
TO
http://www.example.com/product-category-1/product-sub-category.html
This is so that people don't end up with a 404 error when they enter the site via an old URL.
Try adding this to the htaccess file in your document root, preferably above any rules you may already have there:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L]
If you want to redirect the browser so that the new URL appears in the location bar, add an R flag in square brackets:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L,R=301]
I want to redirect all files in a subdirectory to their new root URL.
Old URLS are
www.domain.com/subdirectory/filename-here.html
New location is
www.domain.com/filename.here.html
Old URLs are listed in Google already and need some sort of redirect for these.
I'm sure htaccess is the way to go here, but unsure of the solution.
RewriteEngine on
RewriteRule %{REQUEST_URI} ^/subdirectory/.*
RewriteRule subdirectory/(.*)$ /$1 [R=301,L]
Tested on here. If it would not work - add shielding to [^/] in this way: [^\/]
I'm looking to redirect property listings to a new subdomain and domain structure. For example, I would like to redirect
http://www.example.com/idx/details.php?thenALongString...
to
http://mls.example.com/idx/3494/details.php?thenALongString...
Any help would be much appreciated!
I think this should work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^idx/details.php http://mls.example.com/idx/3494/details.php [R=301,L]
I was able to figure it out. I used the following:
RedirectMatch 301 /idx/details.php(.*) http://mls.lisasellspontevedra.com/idx/3494/details.php
The dynamic string on the old URL is transferred over to the end of the new location.
I am a newbie and would like to redirect all my old urls to new ones (moved as subfolder) via htaccess. Also, with 301 permanent redirect.
Old url pattern looks like:
http://www.mydomain.com/de/myoldpage.html
New url pattern should be:
http://www.mydomain.com/shop/de/myoldpage.html
I am using the same domain and same page urls but only my shop is moved to a subfolder "shop".
How can i write a redirect rule to redirect all the urls in this pattern.
Thanks in advance.
Try this code in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^(de/.*)$ /shop/$1 [L,R=301,NC]
RewriteEngine On
RewriteRule ^de/(.*)$ shop/de/$1 [L,R]