URL Masking!With Htaccess - .htaccess

I'm quite new here so i have a problem about masking and tried other solutions using .htaccess as well but no luck, that's why im here. Thanks.
Ok here's it is:
I want my http://www.domain.com/article-tip to show in http://www.subdomain.domain.com
It means the page content is from: domain.com/article-tip
But the url above the address is: subdomain.domain.com
How would i do that using .htaccess?
It means i also tried the iframe and frames and php, but i want the .htaccess
Thanks in advance.!

you can use mod_rewrite in that case the URL will be subdomain.domain.com/article-tip but in php URL will be www.domain.com/article-tip.
I don't think you can send dynamic output to browser like what you want with .htaccess

This should work for what you need to get all files in article-tip to point to the subdomain. The subdomain should also point to the subdirectory. This is for the .htaccess of the subdirectory.
RewriteRule ^article-tip(.*)$ http://subdomain.domain.com [R=301,L]
RewriteRule ^article-tip/(.*)$ http://subdomain.domain.com/$1 [R=301,L]

Related

Htaccess and redirect all content of folder, but exlude the main folder

I got the following urls:
domain.com/categoryA/articleA
domain.com/categoryA/articleB
I want to redirect:
domain.com/categoryA/articleA -> domain.com/categoryB/articleA
domain.com/categoryA/articleB -> domain.com/categoryB/articleB
but leave it as it is and do not redirect the main folder: domain.com/categoryA/
I tried to use the rule:
RewriteRule ^categoryA/(.*)$ /categoryB/$1 [R=301,NC,L]
but it also redirect domain.com/categoryA/ to domain.com/categoryB/
How to exclude from the above rewrite rule the redirection of the main folder (categoryA), but still redirect all that is in the folder (and then change also the root folder)?
I am looking for a solution that is SEO friendly (I got the same articles in two categories, but want still to have indexed domain.com/categoryA, but the rest only as domain.com/categoryB/xxx.
Best Greetings,
Mat
With your shown samples/attempts, please try following Rules in your .htaccess file. Please make sure to place this rule under your domain redirect rule(if its there), also make sure to clear your browser cache before testing your URLs.
RewriteRule ^categoryA/([\w-]+)/?$ /categoryB/$1 [R=301,NC,L]

Redirect 301 www.example.com/directory/tour1 to www.example.com/tour1

Hi I have a situation with the mytic HTACCESS file. Im trying to fix a broken URL.
this folder never existed was a permalink created in WP.I need to redirect 301 all this broken links to avoid problems with Google.
The URL used to be like this
www.example.com/directory/tour1, www.example.com/directory/tour2, www.example.com/directory/tour3 and so on.
Now the url has changed so all the tours are under the root
www.example.com/tour1, www.example.com/tour2...
I need to make that all the queries to www.example.com/directory/WHATEVER
to point to www.example.com/WHATEVER
Thanks for helping me understand this universe of redirections... \
i HAVE TRIED alot of codes, none of them does the job.
RewriteRule ^tulum-tours/(.*) http://www.aguaclaraproject.com/
In your .htaccess in your www-root use the following rule:
RewriteEngine on
RewriteRule ^tulum-tours/(.*)$ /$1 [R,L]
Change the R flag to R=301 after testing it works correctly. Read the documentation for more information.

Redirecting /folder/ to /file.html in magento

We published an article in the magazine with following url:
http://magnetic-sleep-machine.com/moves
Now we need to make sure when people put that URL they land to
https://magnetic-sleep-machine.com/moves.html
Please help me figure this out! .htaccess or use a magento (1.7) option?
There's a way to redirect using magento, but not sure if that's exactly what you want.
You could also try turning on multiviews, and let mod_negotiation take cure of fuzzy URL-file mapping, in your htaccess file:
Options +Multiviews
Or using mod_rewrite:
RewriteEngine On
RewriteRule ^moves/?$ /moves.html [L,R=301]
Or using mod_alias:
RedirectMatch 301 ^/moves/?$ /moves.html
Okay I found the way to do it using magento itself.
created a new Page
page link named as "moves"
added javascript for redirect to body of the page
next went to system>config>web>
set Auto-redirect to Base URL to NO
Voila, it works now.

.htaccess for cakephp

I am runing a site wishberry.in on cakephp framework. I had some dirty URLs previously and now i want them to cleanup through .htaccess
I original url was wishberry.in/createwishlist3 and i want to change that to wishberry.in/brands with a 301 redirect.
The reason for using 301 is, if someone type wishberry.in/createwishlist3, the page will take them to /brands automatically.
Can anyone help me out what to write in my .htaccess file.
I would recommend doing this with routes in CakePHP rather than the .htaccess file. See http://bakery.cakephp.org/articles/Frank/2009/11/02/cakephp-s-routing-explained for more details.
The following should do the trick:
RewriteEngine On
RewriteRule ^createwishlist3$ /brands [R=301,L,NC]
Hope this helps.

How can I redirect to a different domain without changing the URL in the address bar?

I want to redirect from:
domain1.com/photos
To:
domain2.com/photos
I want the URL in the address bar to still read:
domain1.com/photos
Is there a way to do this using only .htaccess?
Note:
My .htaccess file for domain1.com is currently completely blank.
No, there isn't a way to do this with .htaccess. Doing so would present a glaring security hole - imagine someone doing this with a bank's website!
If both are hosted on the same server, do this in your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.com$
RewriteRule (.*)$ http://www.domain2.com$1 [P]
</IfModule>
If you own both domain1 and domain2, you could accomplish this through domain name forwarding. Check your domain name registrar (like godaddy.com) for the options.
No, you can not do it through htaccess file.
You could open an iframe in domain1.com/photos that shows the contents of domain2.com/photos. But then the url would never change from domain1.com/photos, even when you went to a different page in domain2.
What are you trying to do? It sounds very sketchy. Do you own both domains? Why would you want to duplicate the contents of one site at another address?
Why is this not possible? Seems like a reasonable task as long as your Apache has mod_proxy installed:
ProxyPass /photos http://domain2.com/photos/
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxypass
A way around it, if the page at domain.com/photos is a server side script, do an HTTP call and serve up the response.
In ColdFusion:
<cfhttp url="another.domain.com/photos">
<cfoutput>#CFHTTP.FileContent#</cfoutput>
They'll be an extra request, but it'll get you the output you want.
its impossible using htaccess file.

Resources