| #301 Redirects for .htaccess | |
| #Redirect a single page: | |
| Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
| #Redirect an entire site: | |
| Redirect 301 / http://www.domain.com/ | |
| #Redirect an entire site to a sub folder | |
| Redirect 301 / http://www.domain.com/subfolder/ | |
| #Redirect a sub folder to another site | |
| Redirect 301 /subfolder http://www.domain.com/ | |
| #This will redirect any file with the .html extension to use the same filename but use the .php extension instead. | |
| RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php | |
| ## | |
| #You can also perform 301 redirects using rewriting via .htaccess. | |
| ## | |
| #Redirect from old domain to new domain | |
| RewriteEngine on | |
| RewriteBase / | |
| RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] | |
| #Redirect to www location | |
| RewriteEngine on | |
| RewriteBase / | |
| rewritecond %{http_host} ^domain.com [nc] | |
| rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] | |
| #Redirect to www location with subdirectory | |
| RewriteEngine on | |
| RewriteBase / | |
| RewriteCond %{HTTP_HOST} domain.com [NC] | |
| RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC] | |
| #Redirect from old domain to new domain with full path and query string: | |
| Options +FollowSymLinks | |
| RewriteEngine On | |
| RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC] | |
| #Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string: | |
| Options +FollowSymLinks | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$ | |
| RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC] | |
| Rewrite and redirect URLs with query parameters (files placed in root directory) | |
| Original URL: | |
| http://www.example.com/index.php?id=1 | |
| Desired destination URL: | |
| http://www.example.com/path-to-new-location/ | |
| .htaccess syntax: | |
| RewriteEngine on | |
| RewriteCond %{QUERY_STRING} id=1 | |
| RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301] | |
| Redirect URLs with query parameters (files placed in subdirectory) | |
| Original URL: | |
| http://www.example.com/sub-dir/index.php?id=1 | |
| Desired destination URL: | |
| http://www.example.com/path-to-new-location/ | |
| .htaccess syntax: | |
| RewriteEngine on | |
| RewriteCond %{QUERY_STRING} id=1 | |
| RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301] | |
| Redirect one clean URL to a new clean URL | |
| Original URL: | |
| http://www.example.com/old-page/ | |
| Desired destination URL: | |
| http://www.example.com/new-page/ | |
| .htaccess syntax: | |
| RewriteEngine On | |
| RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L] | |
| Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level | |
| Original URL: | |
| http://www.example.com/index.php?id=100 | |
| Desired destination URL: | |
| http://www.example.com/100/ | |
| .htaccess syntax: | |
| RewriteEngine On | |
| RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA] | |
| Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory | |
| Original URL: | |
| http://www.example.com/index.php?category=fish | |
| Desired destination URL: | |
| http://www.example.com/category/fish/ | |
| .htaccess syntax: | |
| RewriteEngine On | |
| RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA] | |
| Domain change – redirect all incoming request from old to new domain (retain path) | |
| RewriteEngine on | |
| RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC] | |
| RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] | |
| If you do not want to pass the path in the request to the new domain, change the last row to: | |
| RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L] | |
| #From blog.oldsite.com -> www.somewhere.com/blog/ | |
| retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/ | |
| Options +FollowSymLinks | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_URI}/ blog | |
| RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC] | |
| RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC] |
This comment has been minimized.
This comment has been minimized.
|
@purse9644, in order to redirect from your original URL to the new desired destination, you can do the following:
|
This comment has been minimized.
This comment has been minimized.
|
Is it possible to redirect from /example/ to /example/index.php? |
This comment has been minimized.
This comment has been minimized.
|
Hi I tried most of the examples above and testthis.dk/start-here results in this arbejdhjemme.comstart-here (no slash) :-( |
This comment has been minimized.
This comment has been minimized.
|
Hi, do you know how to redirect always (in all subfolders) from myweb.com/index.php to myweb.com/ |
This comment has been minimized.
This comment has been minimized.
|
Great examples, but I have one a little more complex that I can't figure out. Old website had blog entries in mywebsite.com/blog/year/month/blog-name. New site is just mywebsite.com/blog-name. For example: mywebsite.com/blog/2013/06/my-blog-name needs to redirect to mywebsite.com/my-blog-name. Any help is greatly appreciated. |
This comment has been minimized.
This comment has been minimized.
|
How to redirect from a folder into that folder's subfolder ? www.example.com/afolder/ -> www.example.com/afolder/targetfolder/ |
This comment has been minimized.
This comment has been minimized.
|
Thanks man, this just saved me a whole bunch of time! |
This comment has been minimized.
This comment has been minimized.
|
Hi! |
This comment has been minimized.
This comment has been minimized.
|
I'm attempting to redirect URLs that have multiple parameters for example: http://www.example.com/index.php?p=product&id=10&parent=0 to a clean URL on another domain like http://example2.com/product/product10/ Can anybody give me a few pointers please? |
This comment has been minimized.
This comment has been minimized.
|
Hey, how can i redirect old domain to new domain while retaining the path after the old domain name. for instance oldomain.com/test/ to newdomain.com/test/ |
This comment has been minimized.
This comment has been minimized.
|
Dear Friends, |
This comment has been minimized.
This comment has been minimized.
|
This is a terrific post. Just wanted to add: if you have a Wordpress site with a permalink htaccess directive already in place, AND you wish to do a 301 from domainx.com to domainy.com/subfolder, then you need to do this: Redirect 301 / http://domainy.com/subfolder? Adding the "?" will add a "?" at the end of the redirect URL. This will force the browser to view anything after the "?" as parameters. Otherwise, the permalink redirect will "break" your 301 redirect. And if you remove the permalink redirect, you're going to break the 301 redirect. I found this out the hard way by banging my head against the server for like a week. |
This comment has been minimized.
This comment has been minimized.
|
Thank you very much for this incredible helpful gist :) everything I need to know about .htaccess files in one place |
This comment has been minimized.
This comment has been minimized.
|
Hello, http://www.mysite.com/cartypes.php?cartype=123 and the akin permalink http://www.mysite.com/red.php the above works great. Now on a different server with a different site root. I have it so were a person to come using http://m.mysite.com they see the mobile site. this all works fine but then I want to use a perma link for this. thus. This site which has its own site root. I have added Redirect 301 /cartypes.php?cartype=12 http://m.mysite.com/red.php the above gives me a 404 yet were i to go to http://m.mysite.com /cartypes.php?cartype=12 I see the related page. I have tried everything and been to a thosand webpages looking to resolve this. thus am very grateful for any input your side. regards |
This comment has been minimized.
This comment has been minimized.
|
Hello, |
This comment has been minimized.
This comment has been minimized.
|
Can anybody help? |
This comment has been minimized.
This comment has been minimized.
|
Just wanted to add: |
This comment has been minimized.
This comment has been minimized.
|
i m working with core php i want to make it like |
This comment has been minimized.
This comment has been minimized.
|
Here's what I'm having a problem with... Is this an .htaccess thing? Thanks in advance! |
This comment has been minimized.
This comment has been minimized.
|
Hi All, Any help is greatly appreciated? |
This comment has been minimized.
This comment has been minimized.
|
Files moved to another directory: test-a >> test-b http://www.domain.com/Test-A.htm?variable=1&pathvar=tests/test-a/ The htaccess file is located in the root of the web project and works fine for other rewrites, but not for this one: Does anyone see the problem? Thanks in advance. |
This comment has been minimized.
This comment has been minimized.
|
Hi, Google showing Duplicate Title and description Tags Errors in GWT under HTML Improvements duplicate meta description - 4 and duplicate title tags - 4. /sign-up.html / So, I need search engines not to index the ?m parameter at the end of my website url. I guess this is a development issue. In the .htaccess I found the code below that might lead to the m parameter issue on google. Does someone know how to fix it? Redirect urls based on a query string parameterRewriteCond %{QUERY_STRING} ^(.&)?view=mobile([^&])&?(.)?$ RewriteCond %{QUERY_STRING} ^m_(.&)?view=full([^&])&?(._)?$ I am also confused because my mobile version is /mobile and not m? so I don't understand how Google managed to index the m parameter. Also when I inserted the canonical url on the /mobile version and the alternate url on the desktop version google mobile search delivered the following www.mysite.com (mobile-friendly) www.mysite.com/mobile/sign-up.com (mobile-friendly) but before the changes: www.mysite.com (mobile-friendly) www.mysite.com/sign-up.com (mobile-friendly) So this tells me that google detected the mobile site regardless of the changes I made after. As you can see it says Mobile-Friendly (www.mysite.com/sign-up.com) So if it wasn't for the ?m parameter I would not have any duplicate content. So how am I to fix this? It is a nightmare. |
This comment has been minimized.
This comment has been minimized.
|
Hi! http://www.url.com/distribution-city/?distributor=MFhc I'm stumped. Please and thanks in advance! -Sean |
This comment has been minimized.
This comment has been minimized.
|
Hi, I have two below 301 redirects on my htaccess file. Redirect 301 /test/sample /newurl When I tried to check /test/sample/redirect, it should be redireced to /subpage however, it is being redirected to "newurl/redirect" which leads to 404 page. I have tried with changing the order as well on the htaccess file, but no luck. Could anyone please help me to solve this. Thanks in advance. |
This comment has been minimized.
This comment has been minimized.
|
Hi, first of all, congratulation! Very helpful info. |
This comment has been minimized.
This comment has been minimized.
|
So, my conclusions are that can't create an universal rule. The rule which i use is OK, RewriteRule ^(.)/(.)$ /$2 [R=301,L] but also redirect the other resources like css, js, jpg etc. I use three rules to do what I want: RewriteRule ^my-category/(.)$ /my-category [R=301,L] It will be great if somebody give some optimization. |
This comment has been minimized.
This comment has been minimized.
|
Hi, is it possible to create a 301 redirect for the following URL string oldpage.php //:http:www.example.com / newpage.php |
This comment has been minimized.
This comment has been minimized.
|
good informent. |
This comment has been minimized.
This comment has been minimized.
|
Hi, What if I want to reach this: How can I write a condition? |
This comment has been minimized.
This comment has been minimized.
|
Hi, Thanks. |
This comment has been minimized.
This comment has been minimized.
|
Hi Scott. This is a great gist, thank you! I'm hoping you can help me do the following and I apologize if it's already been answered in your post or the comments, I'm not very familiar with Apache and am not always sure of what I'm reading. I want to redirect http://domain.com to http://blog.domain.com - I've got that part by using this:
However, I'd also like to have requests to https://domain.com/subdirectory not be rewritten/redirected. Currently any attempt to access a subdirectory gets redirected to http://blog.domain.com. Can you please advise? |
This comment has been minimized.
This comment has been minimized.
|
Hi Scott, Can you please help me to stop https redirect for a particular url, Please find my current .htaccess sslRewriteCond %{HTTP_HOST} ^www.domain.com [NC] I want below url to not redirect on https https://www.domain.com/setup/abc/{ID} basically i want urls not to redirect which are including "/setup/" Any help will be much appreciated |
This comment has been minimized.
This comment has been minimized.
|
Hi Scott, I have a tricky redirect and hoping you or someone can help me. The redirect I need must remove both numbers and ".html", so all the URLs with a number at the end. Example: Thank you in advance! |
This comment has been minimized.
This comment has been minimized.
|
Hi ! Options +FollowSymlinks When i use this method for redirectpermanent, it does'nt work (error 500). I have searched for some ideas everywhere, but Nothing seems to work...any help will be much appreciated !! Thank you in advance ! |
This comment has been minimized.
This comment has been minimized.
|
current url: http://kheralab.com/agra1/cat.php?url=shi-ram-mantras Expected url: http://kheralab.com/agra1/cat.php/shi-ram-mantras what is the code i have to use can u suggest me?? |
This comment has been minimized.
This comment has been minimized.
|
Can you please help me in making some redirects, i will mention them below: anavasis.gr to https://www.anavasis.gr please give all the text i have to put to .htaccess because i have no knowledge about the specific purpose |
This comment has been minimized.
This comment has been minimized.
|
I'm a little bit confused about these URL REWRITE rules so I'll ask directly my need ;) It's a little bit non common but I would like to REDIRECT everyone going to the "/" path to a http://newdomain.com straight forward but URL REWRITE the rest of the URL if filled (a subfolder + file like "/subfolder/XXX.YYY" or even only a file like "/XXX.YYY") Could you help me figure it out please? :) |
This comment has been minimized.
This comment has been minimized.
|
I am little bit in trouble here . don't have a host but have a domain and also wanna redirect this domain to another domains subdomain. Is it possible to achieve this without using .htaccess?
Can you please direct me to the right direction? |
This comment has been minimized.
This comment has been minimized.
|
How to Redirect specific page on specific domain alias to https/SSL. The webhosting is setup with multiple domain aliases on the same vhost. It needs to redirect a specific page on a specific domain alias to https. domain-a.com http://www.domain-c.com/contact needs to redirect to https://www.domain-c.com/contact The other domains, domain-a.com and domain-b.com don't need to redirect /contact to https |
This comment has been minimized.
This comment has been minimized.
|
Hi, Thanks in advance |
This comment has been minimized.
This comment has been minimized.
|
Hi, can you please help me to resolve my below issue : I have one domain named I want to access admin url using this url : I have project in CakePHP 3.x. So Can you please tell me that how can I achieve this functionality ? Thanks in Advance. |
This comment has been minimized.
This comment has been minimized.
|
Hi Guys, I want to redirect few folders and subfolders from one domain to another domain with different folder names (page names), first level pages are redirecting bu on second level I get 404 . |
This comment has been minimized.
This comment has been minimized.
|
Hi guys, so I've got a wordpress site which looks like: OLDURL.com and I need to redirect all pages sharing that same root URL to: subdomain.NEWURL.com How do I do this without going in and adding manual redirects to every single page? |
This comment has been minimized.
This comment has been minimized.
Thank you very much for this incredible helpful gist :) everything I need to know about .htaccess files in one place Exactly. Cheers |
This comment has been minimized.
This comment has been minimized.
|
Hi, Thanks for this great article. But my situation is a little bit more complex. Do you know how to redirect the following urls: Old: https://twpeach.blogspot.com/2014/12/emilys-day.html Which comes with different domain name & different post id though! Thanks a bunch!! |
This comment has been minimized.
This comment has been minimized.
|
Hi, I tried with rewriterule: Why rewriterule change order of parameter lang and anchor #CONTACT??? |
This comment has been minimized.
This comment has been minimized.
|
I've been playing with this for a week with no luck, maybe you can help me. I want to 301 Redirect...... http://site123.com/t/[number] Would greatly appreciate any help. |
This comment has been minimized.
This comment has been minimized.
|
hii hope anyone can help my problem is i have this rule in my htaccess with some other rules RewriteEngine On what it basically does that it takes the slug value and pass it to the work-single.php . So my only one page work-single.php is used to show my all projects. work is the virtual directory which does not exist in real but it is added on url what I want to do is like when ever any user enter like ex -[ ("upasna-group-self-branding") this will change from project to project it is comming from other page or database ] https://www.mydomain.com/work/upasna-group-self-branding/ I want them to redirect to and when they enter like https://www.mydomain.com/work/ or https://www.mydomain.com/work i want them to redirect back to https://www.mydomain.com/ourwork.php please help me to write this |
This comment has been minimized.
This comment has been minimized.
|
I want redirect when people try to browse through the /includes/ sub-directory of my website (where the java scripts and config files are), but when I do it, all the java scripts don't work on the site. Is there a way to do this without breaking java script? |
This comment has been minimized.
This comment has been minimized.
|
Redirect to different domain. Expected url: https://www.sbs-studies.gr what is the code i have to use can u suggest me?? |
This comment has been minimized.
This comment has been minimized.
|
Excellent piece of script set |
This comment has been minimized.
This comment has been minimized.
|
Only this worked for me with wordpress
|
This comment has been minimized.
This comment has been minimized.
|
how to rewrite my url to without .php extension |
This comment has been minimized.
This comment has been minimized.
|
Question about 301 redirect / modrewrite Pleas I would apprec iate any help in you understand mod rewrite... here is my current URL : mysite.net/doc.php?title=john needs to redirect to : mysite.net/doc.php?renamed=john&id=3340 so am adding 'id' and renaming the variable 'title'. does anyone know the setting for this ?? |
This comment has been minimized.
This comment has been minimized.
|
i want to redirect page manual enter 1 url then auto redirect main domain and 2 url. |
This comment has been minimized.
This comment has been minimized.
|
It looks its good post for my problem, I have website hosted in openshift for instance http://example-products.rhcloud.com/allProducts and this will list out all the available products but if query param added to the above url like this http://example-products.rhcloud.com/allProducts?prodId=25, it displays only one product and everything working fine. But I have created domain in godaddy for instance http://products.com and forwarding to http://example-products.rhcloud.com/allProducts which is working but when I add query param to http://products.com/?prodId=25, its not working. What is the problem and what should be done in order forward the request to http://example-products.rhcloud.com/allProducts?prodId=25 from domain http://products.com/?prodId=25 with query param |
This comment has been minimized.
This comment has been minimized.
|
Try adding (.*) at the end. |
This comment has been minimized.
This comment has been minimized.
|
For some reason when i add this 'redirectMatch 301 ^(.*).html $1' to .htaccess i get: |
This comment has been minimized.
This comment has been minimized.
|
I'm trying to figure out how to do this type of redirect: change this: Any suggestions? I'm basically trying to just reverse this one: |
This comment has been minimized.
This comment has been minimized.
|
How to do this type of redirect: |
This comment has been minimized.
This comment has been minimized.
|
Hi I want to redirect my old domain each every pages to my new domain www.olddomain/news How to do this kind of redirection |
This comment has been minimized.
This comment has been minimized.
|
Hi Sir, i have a search textbox in default .php and redirect from jquery in window.location i get the parameter variable from search.php i used this rule but i cannot get the way i want below to look this way. Please help me.? |
This comment has been minimized.
This comment has been minimized.
|
Thanks for this! Huge help! |
This comment has been minimized.
This comment has been minimized.
|
How to use [L] transparent to make a redirect a directory file url be in the site index E.g |
This comment has been minimized.
This comment has been minimized.
|
I have a bit of a curious one. I had a former WordPress website, let's call it http://example.com. Full blown site, with pages, posts, categories, tags, etc. I want to redirect every single URL from example.com to https://newwebsite.com/page I set up a site redirect at the domain registrar to do that, but now I get many 404s upon redirection, like https://newwebsite.com/page/tags/tag1 or https://newwebsite.com/category/category1 or https://newwebsite.com/page/post5 and the like I'm not sure if I can use the .hatccess file at https://newwebsite.com to accomplish this or if I have to set something up at the registrar for example.com. Any ideas? Solved my own problem. Maybe this will help someone else:
RewriteEngine on ErrorDocument 404 https://newwebsite.com/page/ |
This comment has been minimized.
This comment has been minimized.
|
Possible to do redirect for www.example.com/abc -> abc.example.com in both cases, the root directories are same, need to redirect to a subdomain without affecting the project execution. |
This comment has been minimized.
This comment has been minimized.
|
In cakephp 3 is Possible to redirect. |
This comment has been minimized.
This comment has been minimized.
|
Having a bit of trouble working this out . Old URL I want to redirect any /subdir/ path including anything passed via GET string to the newdomain ex: or http://foo.com/subdir/othersubdir Thanks in advance |
This comment has been minimized.
This comment has been minimized.
|
hi guys, how can I redirect all the pages of www.canlibahis.io to www.canlibahisio.com, keeping the same url structure? The site is already copied on the new domain. Thanks |
This comment has been minimized.
This comment has been minimized.
|
Hello, this is to force to index file rather than just mysite.com it will give mysite.com/index.phpRewriteEngine On #only for the root directory the above works great, when ever a punter goes to mydomin.com it directs the punter to mydomain.com/index.php I have an issue thought how can I force were someone to just type mysite.com/fr/ to force going to mysite.com/fr/index.php Thank you for looking anyway lol cheers |
This comment has been minimized.
This comment has been minimized.
|
I have an entire website that I want to redirect to a new website folder. Any direction would be appreciated. |
This comment has been minimized.
This comment has been minimized.
|
Hi, I have a small problem I hope someone can help me I redirected all articles made in wordpress from /%category%/%post-name%/ to /%post-name%/ to make this i use this in htaccess RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/]+)/$ https://www.site.com/$3 all is fine, categories url are rispected, but i have problem with pagination when category is like https://www.site.com/category/ instead is ok with https://www.site.com/category/sub-category/ how can i solve? thanks! |
This comment has been minimized.
This comment has been minimized.
|
Hi, how can i redirect all links of my site : https://www.mysite.com/mywordpressfolder/ both mysite.com and mywordpressfolder has separate WordPress installed. I am helpless as of now ! Thanks in advnace |
This comment has been minimized.
This comment has been minimized.
|
i want to rewrite i want to make it like |
This comment has been minimized.
This comment has been minimized.
|
thanks in advance |
This comment has been minimized.
This comment has been minimized.
|
@viswanathkk Buy a domain from your hosting provider and you will have a dinkhoo.com ;) |
This comment has been minimized.
This comment has been minimized.
|
original redirect masked More or less trying to obtain a pretty link for the sites root for any number 0 to 99,999 Additionally, www.example.com/1234 should be displayed in the browser no matter if the request url is www.example.com/1234 or www.example.com/?id=1234 Essentially reverse protected. Possible? |
This comment has been minimized.
This comment has been minimized.
|
i want to redirect my images from google images search to my page where those images are existing on my site so i need .htacces code to do something like this. please help me |
This comment has been minimized.
This comment has been minimized.
|
Hello, In my website, I have some urls with the following shape : There is no need neither to display nor to index such Urls (crawled only by robots but not used by website visitor) I wonder whether it is possible to **make a 301 redirection :
I thank anyone in advance for any help in this matter. Patrick |
This comment has been minimized.
This comment has been minimized.
|
HI! |
This comment has been minimized.
This comment has been minimized.
|
redirect 301 |
This comment has been minimized.
This comment has been minimized.
|
My problem is URL should look like http://example/test-2.html but content should come from http://example/test.html?p=2. Please help how to achieve it with htaccess file. |
This comment has been minimized.
This comment has been minimized.
|
Hi, I want to mask olddomain.com/folder to newdomain.com and want to keep the domain constant to newdomain.com not matter I click on any link but the domain should be newdomain.com Please help |
This comment has been minimized.
This comment has been minimized.
|
I moving my drupal site index.html from www.example.com/demo to www.example.com while keeping all the js, css, images, font etc within the "demo" folder. I no longer want to display "demo" in the url but still the js, css urls will have demo in them. What would be my redirect condition or rewrite rule in this case? |
This comment has been minimized.
This comment has been minimized.
|
Hi, I hope someone can point out what I am doing wrong in my .htaccess file I have a domain which has 2 folders - folder1 & folder2 Unless the request is specifically for folder2, I want to redirect all (old) visitors to folder1 RewriteEngine on gives a 500 error Any suggestions what could be amiss would be deeply appreciated I fixed it - solution below RewriteCond %{HTTP_HOST} ^www.domain.ext$ |
This comment has been minimized.
This comment has been minimized.
|
Hi.. |
This comment has been minimized.
This comment has been minimized.
|
Hi, I am using wordpress and I have over a thousand html urls which I will have to redirect. Considering the fact that theses urls are hosted outside on a different server( domain) and that the new ones will be hosted on servers is it possible to have a htacces redirect and if so could someone please help me? ( the id is of course a variable) http://www.oldserver.com/?type=pdf&id=id123 ---> http://www.mydomain.com/pdf/id123.pdf Any help would be much appreciated. |
This comment has been minimized.
This comment has been minimized.
|
Hi, |
This comment has been minimized.
This comment has been minimized.
|
Hi, domain1.com/example1 -> domain2.com/example1 |
This comment has been minimized.
This comment has been minimized.
|
Hi I would like to deny direct access to files in an image folder and redirect the "curious" to a specific page. Let's imagine the image folder is located at the root : http://domain.tld/images Can anyone tell me what I should put in the .htaccess file please ? |
This comment has been minimized.
This comment has been minimized.
|
For example So what i want is that wherever Old URL is found in the page just replace it with New URL except its FILE_NAME Tried : Live example : new URL should be except file name whole url need to be changed (just like string replace function) |
This comment has been minimized.
This comment has been minimized.
|
I'm trying to figure out how to lose trailing slashes only for URLs with parameters. Here's my use-case:
When the domain is visited, the Wordpress web server is redirecting the browser to: mainsite.com/gb/page-name/?param1=a&utm_campaign=yup/ which ALMOST works, except that the last parameter is getting an extra slash at the end of it. I'm using a fairly typical WP htaccess file: Any thoughts? Sorry if I overlooked an answer within the actual post, but it seems like this differs from what I saw in the content when I scanned for "param". Thanks, |
This comment has been minimized.
This comment has been minimized.
|
@davidensor try to change permalink structure by removing / (slash) from the end of custom links structure ;) |
This comment has been minimized.
This comment has been minimized.
|
my website is http://www.dailyarts.in/. i Changed permalink url to new structure. Now i am getting 404 error in my posts in search engines results. You can go to http://www.dailyarts.in/2017/10/21/whatsapp-plus-apk-latest-version-download/ to check 404 error But now this is new url- http://www.dailyarts.in/whatsapp-plus-apk-latest-version-download/ |
This comment has been minimized.
This comment has been minimized.
|
I'm working on some htaccess redirects for a few stray pages and have come across a few different varieties of 301s that are confusing me a bit.... I've also found examples of: I'm confused because our current htaccess file has quite a few (working) redirects that look like this: Is there any difference between these? Would I benefit at all from replacing |
This comment has been minimized.
This comment has been minimized.
|
https://mehmetbarun.com.tr/tag/cdn-ayarlari/https/mehmetbarun.com.tr to https://mehmetbarun.com.tr/tag/cdn-ayarlari/ how can I fix all of these errors in all my links |
This comment has been minimized.
This comment has been minimized.
|
Can you help me in redirecting URL this way in http config ? |
This comment has been minimized.
This comment has been minimized.
|
Please could you help me to write a rule to redirect when "%" sign is present after digits(in this example 75). http://internal.www2.test.com/fr/be/images/products/content-75%-ss-ppr__01234_sk621755_s4.jpg -->400 Bad Request The request could not be understood by server due to malformed syntax. |
This comment has been minimized.
This comment has been minimized.
|
@ScottPhillips |
This comment has been minimized.
This comment has been minimized.
|
How to redirect from a title into that search/title ? |
This comment has been minimized.
This comment has been minimized.
|
hi , i want my website redirect from http to https ( only blog folder) example:- www.mysite.com/india/blog/ can any one tell me how to redirect only blog subfolder. www.mysite.com - global website in which htaccess folder i need to update the rule & which particular rule should update, ? Thanks in advance |
This comment has been minimized.
This comment has been minimized.
|
Hello, Following is my sub directory .htaccess rules. Its no longer work.
Basically URL will result in Why its not work. Please let me know. Thanks |
This comment has been minimized.
This comment has been minimized.
|
Hi, I'm building a site that I'd like to allow user to enter using http://www.domain.com/randomstring. I'd like to pick up the 'randomstring' parameter in my index.php file and use its value in the page returned - a bit like bit.ly/123456. However, a 404 error is returned to the client. I added "ErrorDocument 404 /index.php" to .htaccess and that allows this functionality to work, but I'm concerned this approach will hurt SEO. Anyone have advice about how to use a RewriteCond and RewriteRule to handle this better? Thx. |
This comment has been minimized.
This comment has been minimized.
|
This saved me a lot of time, Thanks and keep it up |
This comment has been minimized.
This comment has been minimized.
|
Hi, I'm trying to redirect my old URL which is to https://mysite.com/blog?page=1 Please help, thanks! |
This comment has been minimized.
This comment has been minimized.
|
Hello ScottPhillips, would u please help me to redirect some fake urls which are in subfolders that doesn't exist..., need a simple solution bcz its 1.25 lakhs url .. which does not exist but crawls by google ... -Thanks! |
This comment has been minimized.
This comment has been minimized.
|
Try this
|
This comment has been minimized.
This comment has been minimized.
|
Hi, I'm trying to get this done but can't find the right solution anywhere over the internet. |
This comment has been minimized.
This comment has been minimized.
|
Hello, I am not a dev and not sure how to achieve the following: Current URL: https://mysite.com/listing-dashboard-page/?action=edit&job_id=3775 How can I achieve this? Thanks, |
This comment has been minimized.
This comment has been minimized.
|
Hello, Please how do i archive the following. I want to redirect http://mysite.com/oldfolder/oldfolder/index.php?email='.$email to another subfolder in the same domain.. http://mysite.com/newfolder/index.php?email='.$email Thanks |
This comment has been minimized.
This comment has been minimized.
|
Original URL: Desired destination URL: .htaccess syntax: |
This comment has been minimized.
This comment has been minimized.
|
hii please help me out with this in this |
This comment has been minimized.
This comment has been minimized.
|
Using Godaddy how can I achieve these 3 rewrites? I can not seem to get these 3 right. I keep getting redirects are to many or unable to locate the file when the extension has been enter. |
This comment has been minimized.
This comment has been minimized.
|
I have written code in codeIgniter and have set base url like https://example.com/ and suppose I have a button "View Profile" with href link https://example.com/profile/view but when I click on this button url must be change and url should look like https://example.com/new/profile/view but code written in profile controller should be treat like before. |
This comment has been minimized.
This comment has been minimized.
|
thanks man. great document |
This comment has been minimized.
This comment has been minimized.
|
Hey , I want to redirect Is there any way to do that ? |
This comment has been minimized.
This comment has been minimized.
|
I want redirect Please Help me.... Urgent |
This comment has been minimized.
This comment has been minimized.
|
I want redirect Please Help me.... Urgent help |
This comment has been minimized.
This comment has been minimized.
|
Hi, |
This comment has been minimized.
This comment has been minimized.
|
How to redirect domain.com/index.php to domain.com |
This comment has been minimized.
This comment has been minimized.
|
How can I redirect all pages except home page to /sub-directory? |
This comment has been minimized.
This comment has been minimized.
|
Thank you so much for this, it solved a 500 error that I kept generating when I had made a mistake in setting up my redirects. |
This comment has been minimized.
This comment has been minimized.
|
How about I seem to be able to redirect the activities dir to the studentlife dir. the word pagesmith is part or the url re-writing my CMS uses. I just need to redirect the initial directory. |
This comment has been minimized.
This comment has been minimized.
|
How to redirect form directory |
This comment has been minimized.
This comment has been minimized.
|
I'm struggling with this one ... |
This comment has been minimized.
This comment has been minimized.
|
Hi, So in order to achieve this, I have already put a redirect into the htaccess file inside the document root (public_html)
Inside the htaccess file of the subdirectory I have placed:
This part works so far. I want to use search engine friendly url's (SEF by joomla)
Works as well. Now I have some files that I need to link to from the joomla, that are housed inside the actual public_html folder - the document root. What do I have to add in order to point this link back to the document root? Currently it creates a 404 error (because the content is obviously not present .. its not in the subfolder, the joomla is located in, but the public_html ..) Also the whole loading process seams slow. Is there a better way to redirect this? I think there might be too many redirects, causing it to be slow, but that's just speculation. Thanks for you help. |
This comment has been minimized.
This comment has been minimized.
|
How do I redirect/rewrite this:
to
|
This comment has been minimized.
This comment has been minimized.
I got it working. Problem is, if I have a blog post with an url linking to www.myurl.com/somwhere/deep/details.html, then it that link doesn't work, because it's redirecting to /blog/ |
This comment has been minimized.
This comment has been minimized.
|
Hi i got problem to redirect mobile users to AMP pages with question mark (www.mysite/?amp) I’m looking for a way to automatically redirect mobile users to the amp pages via .htaccess. I would like to redirect not everything on the main domain but rather every single page on its namesake in AMP; example: etc…etc.! |
This comment has been minimized.
This comment has been minimized.
|
How do I redirect from |
This comment has been minimized.
This comment has been minimized.
|
Thank you so much for this, tried so many other resources online for hours and came here and solved my issue in a few minutes |
This comment has been minimized.
This comment has been minimized.
|
Here's one for you. I have an iFrame set up to host an app from another server I control. But, to log out I have to create a button calling a script on the server hosting the app. So how would you create a redirect from that to loop back to the server with the iFrame? As it is it goes to the other server with the app and leave the site, which is what we don't want to do. Your thoughts are appreciated? The logout code is simply |
This comment has been minimized.
This comment has been minimized.
|
How do I redirect all offers.fdazilla.com/[landing pages] to blog.fdazilla.com/offers/[landing pages]? I already put in a url redirct from offers.fdazilla.com to blog.fdazilla.com/offers but then the rest of the url does not carry forward to the new one. |
This comment has been minimized.
This comment has been minimized.
|
My previous website address is: qaz.com/home-page/ I want to redirect all old address to a new domain: wsx.com/home-page/ I could do this for main address: qaz.com redirected to wsx.com/home-page/ correctly with this code: RewriteRule ^/?$ "https://wsx.com/home-page/" [R=301,L] My website CMS is WordPress. can you help to do this issue? |
This comment has been minimized.
This comment has been minimized.
|
Back in 1996, I had a flat-file system, with all html files in the root. Later, I moved the files into various subdirectories. My problem is that a lot of people linked to the old URLs and after all these years are still attempting to go to them. I need to redirect all files with a given string in the name to a specific subdirectory, while not redirecting anything else. For example, all filenames containing "zebra" in the filename are redirected to a file with the same name in the zoo subdirectory, but filenames not containing "zebra" are not redirected. Result: but /ocelot.htm and /aardvark.htm are not redirected, because the filename does not contain the string "zebra" My .htaccess file already contains code to add www to any url the lacks it, and to redirect http to https. |
This comment has been minimized.
This comment has been minimized.
|
only for mobile traffic, I want to redirect all post's to amp but not homepage (in wordpress). only amp for post's how to do in htaccess ?? |
This comment has been minimized.
This comment has been minimized.
|
Hi Please show me... how i can solve it worh htaccess |
This comment has been minimized.
This comment has been minimized.
|
Can you help with redirecting to new page saving original URL in address bar: |
This comment has been minimized.
This comment has been minimized.
|
Can I redirect all visitors comming from (source) http://.bad-domain.com/ to any url like this - https://www.mycompany/mickeymouse.html ? Thanks, |
This comment has been minimized.
This comment has been minimized.
|
Good evening to all, I have this problem: I must redirect few urls that have format like: /```
|
This comment has been minimized.
This comment has been minimized.
|
How can i redirect this url https://api.domain.com/api/v2/operators/3/kiron/authenticateplayer in to this: https://api.domain.com/kiron/authenticateplayer Note: Thanks in advance |
This comment has been minimized.
This comment has been minimized.
|
Hi, what rule could make this work for me? URL: https://domain.biz URL: https://domain.biz/any_other_page I was working with this (but it doesn't work). I tested this in https://htaccess.madewithlove.be/ but doesn't give me the desired results. Any help please? Thanks!!! |
This comment has been minimized.
This comment has been minimized.
|
Can someone help me with this particular rule. The rule would redirect a bunch of URLs that have additional things attached to the ends that have come out of nowhere I can't seem to find info on redirecting to upper level sub folders or posts. |
This comment has been minimized.
This comment has been minimized.
|
Very helpful - thank you very much for this excellent set of examples. |
This comment has been minimized.
This comment has been minimized.
|
Thank you for great examples. Helped me a lot. Also, I used another very helpful resource https://www.301-redirect.online/ for query strings match. |
This comment has been minimized.
This comment has been minimized.
|
https://domain.com/ 404 page |
This comment has been minimized.
This comment has been minimized.
|
How can I redirect this. New link |
This comment has been minimized.
This comment has been minimized.
|
Please help me. I am stuck in this situation |
This comment has been minimized.
This comment has been minimized.
|
RewriteEngine on |
This comment has been minimized.
This comment has been minimized.
|
hi RewriteEngine On and page is being redirected. but the problem is css and js not working on the page. can u please help me? |
This comment has been minimized.
This comment has been minimized.
|
Hi everybody, I want to redirect domain.com. to domain.com It's possible directly with .htaccess file ? |
This comment has been minimized.
This comment has been minimized.
|
Hi, I would like to rewrite the url from https://www.somedomain.com/index.php?page=SOMEPAGE&user=SOMEUSER to https://www.somedomain.com/settings/user/SOMEUSER where settings is the page parameter from the url. My Solution was: RewriteEngine on The problem is, that all files respond with a 404 error code, because the browser seems to think that /settings/user are actual folders on the server. How can I achieve that the actual url path stays the same? |
This comment has been minimized.
This comment has been minimized.
|
Hi, I would like to rewrite the url from https://www.somedomain.com/index.php?cmd=SOMEPAGE&id=SOMEID&name=SOMENAME |
This comment has been minimized.
This comment has been minimized.
|
Hello, Thanks for your help |
This comment has been minimized.
This comment has been minimized.
|
Hello, please I have a search form which contains several fields: (text, city, categories ...) sometimes if the city field is filled but the other fields are not, and sometimes all the fields are filled, you know the search system how it works, then I want to know how to do it with htaccess if certain fields are empty but the others are not. Thanks for your help exemple : |
This comment has been minimized.
This comment has been minimized.
|
I used to have a shopping cart as a folder inside my main website. It began having issues and I decided to abandon it for a different cart. |
This comment has been minimized.
This comment has been minimized.
|
Hello, I'd like to create redirection rules according to the following needs: OLD URLs: NEW URL (same for 3 langx) Can anyone help? |
This comment has been minimized.
This comment has been minimized.
|
Hi im have the following: The redirect is working good , but i would like to exclude that if im requesting to access to http://srvgeo.com/index.html i get to see this file instead of been redirect to http://www.somedomain.com/$1 |
This comment has been minimized.
This comment has been minimized.
|
Hello, I'm using Github pages for a static website and DNS via Godaddy. I'm trying to redirect https://abc.xyz.com to https://xyz.com/abc. Not getting understand how to add subdomain redirection to sub-folder. Both repositories are different "abc" and core one. Is there a way to do it, can anyone help in this? |
This comment has been minimized.
This comment has been minimized.
|
I want redirect Please Help me.... |
This comment has been minimized.
This comment has been minimized.
|
RewriteEngine On Redirect 301 /chalisa/hanuman-chalisa-with-lyrics/ / I think |
This comment has been minimized.
This comment has been minimized.
|
Hi, please can you help with this redirection: https://www.domain.com/index.php/component/users/?view=remind&Itemid=109 What I don't follow is why even this line isn't working: RedirectMatch 301 "https://www.domain.com/index.php/component/users/?view=remind&Itemid=109" "https://www.domain.com/" |
This comment has been minimized.
This comment has been minimized.
|
I just have to thank you, it helped me a lot. :) |
This comment has been minimized.
This comment has been minimized.
|
Dear Friends , Please help me to write the below querry for 301 redirect .htacess (Apache Server ) , removing www & a Folder in between at a same time I want to redirect the below old url : https://www.mydomain.com/tour-package/india/rajasthan to new one https://mydomain.com/tour-package/rajasthan Thankyou |
This comment has been minimized.
This comment has been minimized.
|
How can I force every visitor of my site to go to the only one preferred URL: https://sitename.com? (Initial: http://sitename.com/) Thanks for help! |
This comment has been minimized.
This comment has been minimized.
|
Pls Help me .... I want to redirect https://www.rentalacgurgaon.com/ac-services-in-gurgaon/ to https://www.rentalacgurgaon.com/ |
This comment has been minimized.
This comment has been minimized.
|
@bhaktisansar you can try to use this
This rule will match both You can also use the .htaccess testing tool: https://htaccess.madewithlove.be/ |
This comment has been minimized.
This comment has been minimized.
|
I wrote a little article called "Using .htaccess to forward people to “Today’s” reading." It was for a devotional our pastor wrote. I had to make it so that each day would forward to that day's devotional. It was a neat project. https://medium.com/@nathanpuls/how-to-set-up-sms-text-reminders-for-yourself-with-gmail-51380d3af010 |
This comment has been minimized.
This comment has been minimized.
|
Hi, is it possible to create a 301 redirect for the following URL string oldpage.php free udemy Course available 100% off100% off udemy Course |
This comment has been minimized.
This comment has been minimized.
|
I cannot make this work. I have a testing site of my cart software located in mysite.com/beta/v3 that somehow google indexed and were placing orders on that I knew nothing about. So I am trying to redirect /beta/v3 to the same page on the correct domain, though I use a multistores setup so all my files are at mainstore.com though the same installation also shows as secondstore.com thirdstore.com etc which are in effect virtual domains. I cannot just redirect all /beta/v3 links to / as it would not take them to the correct store. So I need to put in the right domain name. My cart software (opencart 3.0.3.2) uses {SERVER_NAME} as a variable in htaccess so I tried: #Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string: but this doesn't work. |
This comment has been minimized.
This comment has been minimized.
|
Hi, Original URL: i need to redirect it to the same everything i just want to change /shop to be: i have tried most of the examples above but no one worked to me.. Thanks. |
This comment has been minimized.
This comment has been minimized.
Did you found the answer to this? as I'm also having the same issue. |
This comment has been minimized.
This comment has been minimized.
|
Hope you can help. I have a long url which needs to go to a shorter one. there are many page associated with the original that should go to the new one, like wildcarding. Cannot seem to make this work. Origin / New are many pages with .html Hope to hear from you and thank you in advance! |
This comment has been minimized.
Hi, is it possible to create a 301 redirect for the following URL string:
Original URL:
http://www.example.com/old-directory/blog-post-5
Desired destination URL:
http://www.example.com/new-directory/blog-post-5