.htaccess redirect old domain to new domain - .htaccess

I use from http://siteold.com/json/ in my application and can not change it.
and my new domain is http://panel.sitenew.com/json/ . how redirect my old url to new url without change in application ?
this way does not work (in siteold.com) :
RewriteEngine On
Redirect http://siteold.com/json/ http://http://panel.sitenew.com/json/

I don't think it is possible to redirect a URL to another URL. You will have to create a htaccess.txt file to the directory of the website you want to redirect, and then use this code
Redirect /siteold.com/json/ http://panel.sitenew.com/json/
This will redirect the old file path to the new file path. You cannot add http:// to the origin domain as the code doesn't work like that.
Source

Related

Change URL in browser without redirection using htaccess

I have a URL http://domain.com/foo/bar/100. I want to remove /foo/bar from the URL without redirecting it.
Please help me with this problem as I am new for htaccess.
is this URL created by .htaccess rules?
if not: change your document root or add a location directive to the server.

Redirect static html URL to an .htaccess rewritten URL

I have fully static website, now I want to change this website to dynamic. But problem is that static website having good traffic and I do not want to lose that traffic. For the dynamic website I already rewrite the URL using htaccess for SEO reasons. I want to redirect the static url to the rewritten url (which was written by my .htaccess).
(A) Static URL :
www.website.com/examples/java/datatype/boolean/printbooleanvalue.html
(B) Original Dynamic URL:
www.website.com/examples.php?language=?java&category=data-type&subcategory=boolean&exampleurl=print-boolean-value
(C) Rewritted Dynamic URL :
www.website.com/examples/java/data-types/boolean/print-boolean-value
So I want to redirect URL(A) to URL(C). Is there any way to do this ?
You can hardcode the mod rewrite to load the php file when the html file is called.
The SEO friendly url that you have created in your .htaccess is redundant. Instead of the SEO friendly URL, use the same url as your original site.
For example in your .htaccess file write the rule like
RewriteEngine On
RewriteBase /
RewriteRule examples/java/datatype/boolean/printbooleanvalue.html$ /examples.php?language=?java&category=data-type&subcategory=boolean&exampleurl=print-boolean-value [L]
This will load the php file whenever the original html file is requested and it will use the same url as the older one.
Hope that helps.
Your .htaccess code:
Redirect /examples/java/datatype/boolean/printbooleanvalue.html http://www.website.com/examples/java/data-types/boolean/print-boolean-value
In any case you run into the need to redirect:
Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

Need redirect old url to new friendly url

a need redirect
http://www.mysite.com/product.php?id_product=216
to
http://www.mysite.com/category/newProduct.html
I try to add a line in htacces
redirect 301 /product.php?id_product=216 http://www.mysite.com/category/newProduct.html
but dont work.
If I add
Redirect /product.php http://www.mysite.com/category/newProduct.html
All links like
http://www.mysite.com/product.php
http://www.mysite.com/product.php?id_product=216
http://www.mysite.com/product.php?id_product=219
Go to homepage http://www.mysite.com/
Any idea. THX
Check the following:
Make sure your file is called .htaccess, not htaccess as you say above.
If you're using FTP to transfer it to the server, use ASCII rather than binary transfer mode.
Make sure the .htaccess file is in a directory where the Apache AllowOverride directory option is on if you're using apache web server.

mod_rewrite / .htaccess - domain name showing twice in URL

I have an "addon domain" with no specified htaccess file but the main site (of which the add on site is a sub dir) DOES have htaccess which rewrites url to remove the .html prefix.
Anyhow when i go to the addon domain for instance: test.com/about.html it automatically changes to test.com/test.com/about.html
Can anyone point me in the direction to correct this?
If there is no htaccess file with modRewrite in it in a directory, apache goes up to the parent directory to search for it, and this goes up along the tree (this is not affected by having an addon domain or not). So that means that your addon domain is affected by the htaccess file of the parent domain.
What you need to do is create an htaccess file in the subdirectory (the addon domain) and desactivate rewriting :
RewriteEngine Off
Or you can add your own RewriteRules if you want.

301 Redirect old site URL's in new Drupal installation

I'm looking to 301 redirect an URL from a old version of a site no longer being used to a new URL that has been created in fresh Drupal installation.
Old URL: /198/our-software/
New URL: /services/software-development/
In the .htaccess located in the root directory of Drupal I have added the following:
redirect 301 /198/our-software/ http://www.domain.com/services/software-development
The redirect is working to some extent, it sends the user to a url like below with a query string appended to the end of it, which results in a 404 error:
http://www.domain.com/services/software-development?q=198/our-software/
I have tried placing the redirect at both the start and end of the .htaccess file both result in a 404 page not found error.
Do I need to use a more complex redirect to get around Drupals URL rewrite?
NOTE: I'm using the Pathauto module.
Rather than edit the .htaccess directly, just install the Path Redirect module which has that exact functionality built in.
Note that the Path Redirect module is only available for Drupal 6 (as of 2/22/12)
I got it working with using "RewriteRule" instead, AND (important!) removing the leading slash in the source URL, so in your case:
RewriteRule 198/our-software/ http://www.domain.com/services/software-development [R=301,L]

Resources