I have this path www.exemple.com
but my website is in www.exemple.com/website/
is it possible that when someone visits www.exemple.com they are redirected to www.exemple.com/website/?
In your site root .htaccess have this rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} /website/(\S*) [NC]
RewriteRule ^ /%1? [R=302,L,NE]
RewriteRule !^website/ website%{REQUEST_URI} [L,NC]
Related
I'm trying to set up an .htaccess file. I wanted to set it to go to just the route of the current folder if the user include index.php and index.html at the end of the address.
I was want the www to be added to the address if the user missed it out.
I'm running two websites from the same address. One is using the root folder and the other from a folder. The index bit works fine for both but when I set the www, if they miss it out, it goes to the home page on the root rather than the folder.
Could anyone suggest what I need to do here and where I should put the .htaccess file to get it to work?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^candle-light\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.candle-light.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.candle-light.co.uk/ [R=301,L]
</IfModule>
The subfolder is called flickering.
Try these rules with %{REQUEST_URI} variable instead of $1:
RewriteEngine On
# skip POST requests
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]
# add www
RewriteCond %{HTTP_HOST} ^candle-light\.co\.uk$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# remove index.php
RewriteCond %{THE_REQUEST} /index\.(php|html) [NC]
RewriteRule ^(.*)index\.(?:html|php)$ /$1 [L,R=301,NC,NE]
I have canada website, have two version of website ca.domainname.com and canada.domainname.com. I want 301 permenant rediret ca.domainname.com all website to canada.domainname.com through htaccess.tried below code
RewriteCond %{HTTP_HOST} ^CA\.domainmae\.com$ [NC]
RewriteRule ^ http://canada.domainmae.com [L,R]
Changing
RewriteCond %{HTTP_HOST} ^CA\.domainmae\.com$ [NC]
RewriteRule ^ http://canada.domainmae.com [L,R]
to
RewriteRule ^(.*) http://canada.domainmae.com [L,R=301]
should work. Put that in the htaccess file in te root folder of ca.domainmae.com
If you want to be redirected to the corresponding url on the new website you can use:
RewriteRule ^(.*) http://canada.domainmae.com/$1 [L,R=301]
The past couple of hours I am trying to create custom redirects from an old mambo website to new drupal 7 website with the .htaccess file that exists in my drupal's root.
What I want to do is...
301 Redirect
http://mysite.com/index.php?option=com_content&task=blogsection&id=11&Itemid=54
to
http://mysite.com/this-is-the-new-page
This is my .htaccess file...
RewriteEngine on
RewriteRule ^index.php?option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]
RewriteRule "(^|/)\." - [F]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
I am sure that it has something to do with this line...
RewriteRule ^ index.php [L]
But I don't get it!
You see if I use this...
RewriteRule ^option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]
instead of this...
RewriteRule ^index.php?option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]
and test it with firefox and LiveHTTP Headers addon it works!
Any suggestions?!
Thanks!
The query string is not part of the URL path pattern. If you want to base a rule on the query string, you must do so in a RewriteCond
RewriteEngine on
RewriteCond %{QUERY_STRING} option=com_content&task=blogsection&id=11&Itemid=54
RewriteRule ^index.php$ /this-is-the-new-page? [R,L]
I am using Cakephp 2.0 and my website domain name is www.sample.com , If I try to access sample.com (with out www) then its going to www.sample.com this is fine. But My problem is my domain consists of lot of pages
for example :
> http://www.sample.com/users/login
> http://www.sample.com/users/add
If I access the above url like http://sample.com/users/login then it redirect to
> http://www.sample.com/index.php?url=users/login
but it needs to redirect to
http://www.sample.com/users/login
I already written the following code .htaccess file(before the app folder) to redirect
Rewritecond %{http_host} ^sample.com [NC]
Rewriterule ^(.*)$ http://www.sample.com/$1 [R=301,NC]
Inside webroot folder I have one .htacces file that contain the following code
may be that is the problem I think
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Are you trying to always remove www or always keep www? This will add it:
## Add www
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
## CakePHP
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Try to write the next rule:
RewriteCond %{HTTP_HOST} ^sample.com [NC]
RewriteRule ^(.*)$ http://www.sample.com/$1 [L,R=301]
on app/webroot/.htaccess file, not on app's folder .htaccess. It works perfectly for me.
Ok so i have an admin folder in a site that i am working and what i need is when someone enters
http://admin.teamfocususa.org/
in their browser then they get redirected to the admin folder
here is my htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^teamfocususa.org [NC]
RewriteRule ^(.*)$ http://www.teamfocususa.org$1 [L,R=301]
RedirectMatch 301 ^/admin/(.*)$ http://admin.teamfocususa.org/$1
Redirect http://admin.teamfocususa.org /admin
this part is not working
Redirect http://admin.teamfocususa.org /admin
any ideas on how to make this part work ...when i visit http://admin.teamfocususa.org is the home page and not the admin folder as i thought....FYI this is a shared host and I dont have access to the vhost to fix this the way i know
Try adding a RewriteRule matching on requests to / of admin.teamfocususa.org.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^teamfocususa\.org^ [NC]
RewriteRule ^(.*)$ http://www.teamfocususa.org$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?teamfocususa\.org [NC]
RewriteRule ^admin(.*) http://admin.teamfocususa.org/$1 [L,R=301]
# Not needed
#RedirectMatch 301 ^/admin/(.*)$ http://admin.teamfocususa.org/$1
# Added = requests to http://admin.teamfocususa.org/
# Redirected into http://admin.teamfocususa.org/admin
# --OOPS fixed RewriteCond - was typo RewriteRule
RewriteCond %{HTTP_HOST} ^admin\.teamfocususa\.org$ [NC]
RewriteRule ^$ admin/ [L,R=301]
# To hide /admin on admin.teamfocususa.org
# use this instead of the above group...
RewriteCond %{HTTP_HOST} ^admin\.teamfocususa\.org$ [NC]
RewriteRule ^$ admin/ [L]
# Not needed
#Redirect http://admin.teamfocususa.org /admin
I do not think you want to do a Redirect, but a simple RewriteRule to show the admin folder for the domain admin.teamfocususa.org
RewriteEngine On
RewriteBase /
# If not admin.teamfocususa.org and in /admin folder, redirect to admin.teamfocususa.or
RewriteCond %{HTTP_HOST} ^admin.teamfocususa.org [NC]
RewriteRule ^/admin/(.*)$ http://admin.teamfocususa.org/$1 [L,R=301]
# If domain is admin.teamfocususa.org, show files from admin folder
RewriteCond %{HTTP_HOST} admin.teamfocususa.org [NC]
RewriteRule (.*)$ /admin$1 [L]
# if domain is teamfocususa.org, redirect to www.teamfocususa.org
RewriteCond %{HTTP_HOST} ^teamfocususa.org [NC]
RewriteRule ^(.*)$ http://www.teamfocususa.org$1 [L,R=301]
UPDATE: My domain checks were wrong, try this updated version