Base url to virtual folder htaccess - .htaccess

I have my website http://example.com, I would like to redirect to a virtual folder
http://example.com/en (index.php?lang=$1)
How can I do ? :(
I tried with an
Redirect 301 / http://example.com/en
but it didn't work as expected (Error 500). I did not forget
Options +SymLinksIfOwnerMatch
RewriteEngine On

Related

Redirect only a single folder to a new website

I'm trying to redirect an old part of my website to a new website. This part is contained in a folder, http://example.com/infos/.
All pages or subfolders should be redirected to the homepage of the new website,
http://www.new-website.com/
e.g.
http://example.com/infos/ redirects to http://www.new-website.com
http://example.com/infos/test.html redirects to http://www.new-website.com
http://example.com/infos/sub/hello.html redirects to http://www.new-website.com
However I don't want to redirect
http://example.com/
http://example.com/geo.html
http://example.com/test/1.html
I tried the following declaration on a .htaccess file, but it didn't work.
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^infos/(.*)$ http://www.new-web-site.com [R=301,NC,L]
</IfModule>
Could you help me please?
Option 1
This one depends on who you are using to host your website. There might be a redirects button that takes you to a page to add a redirect. You could redirect the whole site (e.g. anything starting with http://example.com/) or just certain folders on the site.
Option 2
Place a file called .htaccess in http://example.com/(root folder) with the following contents:
RedirectMatch 301 ^/my_redirected_folder/ http://www.new-website.com/

301 Redirect a folder to a single page

I have a folder on my website that has been superceded and I want to redirect an attempt to access any file in this folder to the current home page.
I have read many questions here but none seem to do exactly this.
I have tried various things in .htaccess but it seems to always append the filename to the redirect address.
redirect 301 old/$ www.example.com/index.html
redirect 301 old/ www.example.com/index.html
redirect 301 ^old/ www.example.com/index.html
I have seen various mentions of RewriteRule. Do I need to use that?
You can use this code in your /old/.htaccess file:
RewriteEngine On
RewriteRule ^ http://www.example.com/index.html [L]
OR from root .htaccess use:
RewriteEngine On
RewriteRule ^old(/.*)?$ http://www.example.com/index.html [L,NC]

redirect directory to domain htaccess without changing domain url

I have a site sub.domain1.com
But i would like to access to it from the following url: domain2.com/folder
Here is the .htaccess file in domain2.com
RewriteEngine on
RewriteBase /
RewriteRule ^folder/(.*) http://sub.domain1.com/$1 [L,R=301]
This redirection works well but i wouldn't like to change the url to sub.domain1.com
I want to display the content of sub.domain1.com by using the url domain2.com/folder without changing url.
Thanks in advance

htaccess redirect homepage to subdirectory keep url the same

I am trying to figure out how to get my .htaccess to redirect just the homepage URL to a sub directory (domain.com > domain.com/sub/sub ), but I still want the URL to display as domain.com.
I looked around for the past hour and have tried a number of suggestions that I found but nothing worked out.
Any Ideas?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^$ /sub/sub [L]

Problems with htaccess Redirect (Page on one domain to same page on another)

I'm trying to redirect a few pages to a new domain and I have done this before but for some reason I can't get the code to work.
RewriteEngine On
Redirect 301 http://domain.com/page1.html http://domain2.com/page1.html
Can anyone see where I'm going wrong?
In .htaccess file the below code will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Since you say you only want to direct a FEW of your pages and not all of them, you can do:
RewriteEngine On
Redirect /~myaccount/oldpage.html http://www.newsite.com/newpage.html
You specify the path to the page on your current server followed by the URL to redirect to.
OR you can do:
RedirectMatch 301 ^/oldpage\.html$ http://www.newsite.com/newpage.html

Resources