Redirect by .htaccess doesn't work - .htaccess

I want the URL www.michelenerna.nl to be redirected to www.michelenerna.nl/wycliffe.
The actual Joomla path is /wycliffe =
http://www.michelenerna.nl/index.php?option=com_content&view=article&id=97&Itemid=249
So, I thought: the following lines in .htaccess should be appropriate, but it doesn't work. www.michelenerna.nl still directs to www.michelenerna.nl
This is the code:
Options SymlinksIfOwnerMatch
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.michelenerna.nl [NC]
RewriteRule ^article(.*)$ http://www.michelenerna.nl/index.php?option=com_content&view=article&id=97&Itemid=249/$1 [R=301,L]
Why doesn't it work?

Try using the following instead:
RewriteCond %{HTTP_HOST} ^(www.)?michelenerna.nl$ [NC]
RewriteRule ^(/)?$ wycliffe/index.php [L]
You can also achieve this in the your server cPanel by going to the "Redirect" page and selecting the options that apply to you.

The following works for me:
RewriteCond %{HTTP_HOST} ^(www.)?michelenerna.nl$
RewriteRule ^(/)?$ wycliffe [L]

Related

How can i redirect /?lang=en|ru to /?lang=en#googtrans(en|ru)?

How can I add the Google translate parameter #googtrans(en|de) or other language, so the translation happens automatically?
Basically, when the user goes to https://example.com/page/?lang=de they are redirected to https://example.com/page/?lang=en#googtrans(en|de)
I use this .htaccess rule, but it's not working:
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$
RewriteRule ^/?lang=en#googtrans(en|[a-z]{2}) [R=301,L]
EDIT: Adding edited Rules here.
RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/page/?\?lang=([a-z]{2})\s [NC]
RewriteRule ^ page/?lang=%1#googtrans(%1) [R=301,L,NE]
With your shown samples(this is considering that you are hitting URL like: https://example.com/page/?lang=de in browser), please try following .htaccess Rules file. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$ [NC]
RewriteRule ^page/?$ page/?lang=%1#googtrans(%1) [R=301,L,NE]

How to redirect dynamic subdomains with multiple query parameters

I would like to redirect
domain.com/test.php?username=username&code1=849&code2=4d1
to
username.domain.com/849/4d1
with .htaccess
At the moment I have
RewriteRule ^test/([^/]+)/([^/]+)/([^/]+) test.php?username=$1&code1=$2&code2=$3 [NC]
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*) test.php?username=%1&code1=%2&code2=%3 [NC]
The redirect works but the code (php)
$code1 = $_GET['code1'];
echo $code1;
is empty. Can anyone point me in the right direction?
Thanks
Found it!
So if you want to redirect
username.domain.com/849/4d1
to
domain.com/test.php?username=username&code1=849&code2=4d1
You need to add below code to your .htaccess file:
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*)/([^/]+) test.php?username=%1&code1=$1&code2=$2 [NC]

change site path by RewriteRule3

i need change the site url path
from
site.net/open.php?cat=22&book=2285
to
site.net/book/2285
i think this code need edit and complite
RewriteEngine On
RewriteRule ^book/([^/]*)$ /books/open.php?cat=22&book=$1 [L]
how to do it by .htaccess and RewriteRule?
i need code work in all categorys also not 22 only
This code should work for you -
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)cat\=22($|&)
RewriteCond %{QUERY_STRING} (^|&)book\=2285($|&)
RewriteRule ^open\.php$ /book/2285? [L,R=301]

htaccess redirect subdomain into folder that has similiar name with subdomain

I did many way to do this, but always getting 404 error.
I want to redirect subdomain
[username].domain.com/
to
domain.com/user/[username]/index.php
and the url on browser address is not changed still
[username].domain.com/
[username] is dynamic according to registered user in my site.
my last trial httaccess setting is
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(^.*)\.domain\.com$
RewriteRule ^ ^.domain.com/user%{REQUEST_URI} [L,P]
Note: I did set my DNS wildcard *.domain.com
Thanks in advance,
Nanang K
============================================================
SOLVED
I had to create 3 htaccess files.
in root directory (redirect to user)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule ^(.*)$ /user/$1 [NC,L]
in user directory (redirect to username_folder)
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([aA-zZ])$ user/$1/index.php
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule (.*) user/%1/index.php
in username_folder directory (rewrite the url into original url)
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([aA-zZ])$ index.php?siteName=$1
RewriteCond %{HTTP_HOST} ^(^.*)\.domain.com
RewriteRule (.*) index.php?siteName=%1
now, when user access robert.domain.com, he will get the content from domain.com/user/robert/index.php. And the url browser still robert.domain.com
hope helps someone who get similiar problem.
Hello Can you please try this :-
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^(.*)$ /users/$1 [L,NC]
It may use helpful.
It should be like this, try it out.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[username].domain.com$
RewriteRule ^/?$ "http\:\/\/domain\.com\/users\/" [R=301,L]
hope this helps!

htaccess redirect url with domain as variable to an external site

I want to redirect
http://example.com/report?domain=dollarshaveclub.com
to
http://www.semrush.com/info/dollarshaveclub.com+%28by+organic%29
I've tried:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^?domain=$
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [R=301,L]
But I'm not getting anywhere...What could I try next?
You must remove the R=301, part.
This works for me:
RewriteEngine On
RewriteRule ^report$ http://www.semrush.com/info/$1+%28by+organic%29 [NC]
Found the solution finally:
RewriteCond %{QUERY_STRING} ^domain=(.*)
RewriteRule ^report(.*) http://www.semrush.com/info/%1+(by+organic)? [R=301,L]

Resources