How to redirect the url using .htaccess?
Actual url is www.mywebsite.com/index.php/user/john
is need to convert as john.mywebsite.com/
Try this code in .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteEngine On
RewriteRule ^index.php/(.*)/(.*) $2.mywebsite.com/
If you have wildcard Dns, contact your host provider/adminisrator. And request to the line
*.yourdomain.com on server configuration file.
You can write your self on your htaccess file as following,
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourdomain.com
RewriteRule ^(.*)$ /path_to_your_site/subdoamin.php?url=%1
Related
I'm trying to setup a rule in the .htaccess file to allow me to add the 'something' to my website url, like this: something.mywebsite.com redirect to some subdirectory.
I have other rewrite conditions inside my .htaccess file already
Can you do this via .htaccess?
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/somesubdomain [R=301,L]
I am trying to redirect the following (respectively):
http://sub.firstdomain.com/d/(all_files_and_folders)
http://sub.firstdomain.com/d2/(all_files_and_folders)
to
http://sub.seconddomain.com/d/(all_files_and_folders)
http://sub.seconddomain.com/d2/(all_files_and_folders)
There are other files and folders under the first subdomain that I do not want redirected. Previously this was working but now it seems like Go Daddy changed something and what I had is no longer working. Here it is:
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^stats/(.+) /dstats/count.php?statspage=$1 [L,NC,QSA]
RewriteRule ^(.+)\.deb$ /dstats/count.php?file=$1.deb [L,NC,QSA]
RewriteCond %{HTTP_HOST} ^sub\.
RewriteRule ^(d2?)/(.*)$ http://sub.seconddomain.com/$1/$2 [L,R=301]
You can ignore the RewriteRule. It is working fine. I wanted to make sure I included the entire .htaccess file just in case. My issue is with RewriteCond it seems.
The following should work:
RewriteEngine On
Redirect 301 /d/ http://sub.seconddomain.com/d/
Redirect 301 /d2/ http://sub.seconddomain.com/d2/
The above should only redirect anything in the /d/ and /d2/ folder of the sub subdomain.
EDIT: Second try
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub1\.
RewriteRule ^(d2?)/(.*)$ http://sub2.mydomain.com/$1/$2 [L,R=301]
I want to 301 redirect a subdomain to another domain with htaccess.
I want:
A: www.subdomain.domain1.se
B: subdomain.domain1.se
C: subdomain.domain1.se/anything/anything.anything#anything?anything
to redirect to:
A: www.domain2.se
B: www.domain2.se
C: www..domain2.se/anything/anything.anything#anything?anything
Also I need to know where to put the file (in subdomain directory or root directory). Best would be if I could put the htaccess file in the subdomain ddirectory if possible.
I have tried this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^c\.domain1\.se$ [NC]
RewriteRule ^(.*)$ http://www.domain2.se/$1 [QSA,R=301,L]
I think you messing RewriteBase / in the code
regular redirect 301 work like this
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301,NC]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} subdomain\.domain1\.se$ [NC]
RewriteRule ^ http://www.domain2.se%{REQUEST_URI} [R=301,L,NE]
Reference: Apache mod_rewrite Introduction
However note that URL part after hash is not sent to web server hence cannot be handled by Apache mod_rewrite.
The crawling properties of site showing
http://www.abc.com/http://www.abc.com/index.php?option=com_toys
http://www.abc.com/http://www.abc.com/index.php?option=com_article
http://www.abc.com/http://www.abc.com/index.php?option=com_play&view=category&vid=10
The site been crawled like this, with errors coming in as duplicate url. Correct url is
http://www.abc.com/index.php?option=com_toys
http://www.abc.com/index.php?option=com_article
http://www.abc.com/index.php?option=com_play&view=category&vid=10
is there any way to 301 redirect
i tried using
RewriteCond %{REQUEST_URI} ^.*/http://www.abc.com.*$
RewriteRule .* index.php [R=301,L]
But its not achieving the desired as redirecting to http://www.abc.com/index.php
How to redirect through htaccess from incorrect url to correct url sttructure off site
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 /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+http://.+?(/index\.php\?[^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]
Try this code :
RewriteEngine On
RewriteRule ^http://www.abc.com/index.php /index.php [QSA, R=301]
for example
mydomain.com/jobresultpage?what=&where=Arkansas
redirect to
yourdomain.com/jobresultpage?what=&where=Arkansas
but other page like
mydomain.com/about.html
mydomain.com/contact.html
not redirect..
Try adding the rules below to the .htaccess file located in the root directory of mydomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} mydomain\.com$ [NC]
#redirect any request for jobresult to yourdomain
RewriteRule ^jobresultpage$ http://yourdomain.com%{REQUEST_URI} [NC,L,R=301]