I did search for this but so far did not find an answer.
I have a PHP script that is licensed to my main domain: main.com
I have an addon domain referring to the main.com, but not redirecting: addon.com
When I load main.com, it works perfectly, but when I load addon.com, it refuses to work (Because it is not licensed to addon.com).
I want to internally rewrite the URL using htaccess to change addon.com to main.com.
Thank you.
Related
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
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.
I'm stuck with htaccess redirect on this case:
I have myapp.com domain where my main website and service runs on. My customers logs into their accounts on myapp.com and use. Now, I am going to provide one of the features on a separate domain, let's assume "goto.com". However, I don't want to build a separate app on goto.com. I just want to redirect all coming requests to goto.com to a php script under myapp.com but this redirection should be in the backend (masked), not a 301 redirection.
Let me clear up:
myapp.com - /var/www/vhosts/myapp.com/httpdocs/index.php
goto.com --> masked redirection --> myapp.com/goto.php?$1
How can I do this with htaccess? Any suggestions?
Just found that it can be done with redirect [P] (proxy) method: RewriteRule ^(.*)$ http://myapp.com/public_view/$1 [P] What do you think? Is this a good and stable method?
That method is fine, it utilizes the mod_proxy module. The only thing I can suggest is adding the L flag as well in case you have other rules in your htaccess file.
A limitation with using the P flag in an htaccess file is that if a page or request to http://myapp.com/ redirects, then you're URL address bar will say http://myapp.com/ instead of your other domain. The only way around this is to use ProxyPassReverse but it doesn't work in an htaccess file. You'd need access to vhost config:
ProxyPass / http://myapp.com/public_view/
ProxyPassReverse / http://myapp.com/public_view/
Additionally, if http://myapp.com/ sets cookies, you'll need to use the ProxyPassReverseCookieDomain and ProxyPassReverseCookiePath directives to rewrite those.
I have an apache server running in Linux and I'm wondering how I would go about redirecting urls? I want to do this via apache not by adding a header or redirect into the individual files. The goal is to get around having to deal with .aspx
Example1:
VISITING: wwww.myserver.com/file1.aspx
Will take you to: www/myserver.com/file2.php
Example2:
VISITING: www.myserver.com/file1.aspx?command1=set&command2=set
Will take you to: www.myserver.com/file2.php?command1=set&command2=set
Without using mod_rewrite, you can simply use mod_alias, in your vhost/server config or in an htaccess file:
Redirect 301 /file1.aspx /file2.php
I recently moved my sub-domain hosted Joomla (sub.domain.com) to another host and my SEF URL's are broken. Currently I have Apache mod_rewrite turned off in the Joomla admin forcing the /index.php/ within all URL's
Apache mod_rewrite is loaded and working correctly. The major different in my hosting setup is that before my VPS host had a directory for the sub-domain within the server structure /home/me/sub.domain.com/ now it seems the new host is using another rewrite? as the server files is located in /var/www/domain.com whereas the front-end browser points to http://sub.domain.com
Not sure if there is a custom RewriteBase rule I'm not familiar with to correct this or perhaps there is another rewrite going on within the hosting which I'm not aware of?
Thanks for you time.
Have you made sure, that you DO NOT have set AllowOverride in your vhosts file to "none" ?