I want to redirect example.com to example.au,but at the same time i want to exclude example.com/admin from redirection. Is it possible if yes please provide any rewrite rules.Any help would be appreciated.
Code:
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
#RewriteRule .* index.php [L]
RewriteRule ^(.*)$ www.example.com.au/$1 [R=301,L]
RewriteRule !^(admin/.*)$ www.example.com.au/$1 [R=301,L]
You can use following .htaccess redirection code for access admin
GeoIPEnable On
ReWriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} IN$ //IN is the country code where you want to redirect
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_URI} !admin
RewriteCond %{REQUEST_URI} !index.php [NC] //admin keywords
RewriteRule ^ http://www.domain.in [R=301,L] //redirection url
In the above example admin and index.php are the keywords for accessing admin
RewriteCond %{REQUEST_URI} !admin
RewriteCond %{REQUEST_URI} !index.php [NC]
It means redirect to specific url in INDIA,only when the current url doesn't have the above keywords(all admin modules only have these keywords).
It would be help you. I'm also using the above same code for my store
All the best
EDIT : You can refer the following threads too for getting some more details
Some admin modules redirect to frontend
Magento redirection with htaccess based on country wise
Related
Hi I am use Deployer to deploy a Craft CMS website. The site is symlinked to the directory called 'current'. I am using mod rewrite to remove the /current/public from the url in the document root like so:
RewriteEngine On
RewriteCond %{REQUEST_URI} !current/public/
RewriteRule (.*) /current/public/$1 [L]
And inside the current/public folder there is this htaccess to remove the index.php and create nice urls:
RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
Edit - Test
The following works to force HTTPS but I end with urls looking like:
example.com/current/public/about etc
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
How can I adjust this to force the site to always use HTTPS?
This will redirected all http request to https.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www.)?yourdomainname.com
RewriteRule ^(.*)$ https://www.yourdomainname.com/$1 [R,L]
Hope this will help you
The following is what I managed to get working:
RewriteEngine on
RewriteRule ^(.*)$ current/public/$1
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
I've been able to set up .htaccess to enable vanity urls on my website. However, I'm encountering into a problem when I try to clean other urls on my website. I would give the scenario and my current .htaccess below:
Currently wwww.mywebsite.com/john redirects to profile.php?user=john. In profile.php I check to see user john exist in my database if false I redirect to a custom 404.php page. This work very well. The problem arises when I try to have wwww.mywebsite.com/photo/abcdefg be interpreted as www.mywebsite.com/photo.php?m=abcdefg. For some reason it believes photo is the name of the user and then rewrites it as if its a vanity url. Please see my .htaccess file code below:
ErrorDocument 404 http://www.mywebsite.com/404
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC]
RewriteRule ^([^\.]+)$ profile.php?username=$1 [L]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
RewriteRule ^ HTTP%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
You need to do your redirect before any internal routing. Then, you need to explcitly match against /photo before you route to profile and change the .php -f:
ErrorDocument 404 http://www.mywebsite.com/404
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
RewriteRule ^ HTTP%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^photo/(.+)$ /photo.php?m=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^\.]+)$ /$1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ /profile.php?username=$1 [L]
I have joomla in a hosting, and it is working fine.
But I want to create a small webservice for an app, so I created a subfolder in my root folder to have access like this: www.mydomain.com/myfolder
The problem is, the .htaccess is automatically redirecting me to the joomla index. I don't have experience with the .htaccess configuration at all. I have been reading some tutorials, but every time I change something, the joomla stops working properly.
Here is my htaccess file:
rewriterule ^component/users/(.*)$ index.php?option=com_comprofiler&task=login [L]
rewritecond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
rewritecond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
rewritecond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
rewritecond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
rewriterule .* index.php [F]
rewriterule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
rewritecond %{REQUEST_URI} !^/index\.php
rewritecond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewriterule .* index.php [L]
Creating a subdomain is not an option (I only have access to the ftp)
thanks
Right after rewritecond %{REQUEST_URI} !^/index\.php, add:
RewriteCond %{REQUEST_URI} !^/myfolder/
That should exclude any request for /myfolder/ from getting routed to joomla's index.php file.
I am trying to setup a codeigniter app to force HTTPS across all pages except one. However, I cannot get the rules to only redirect if the user is not on the page in question.
The page that should be excluded has the following URL's:
http://mydomain.com/kpi/reports/67
http://mydomain.com/kpi/reports/67/overview/2013-02-01/2013-02-28
http://mydomain.com/index.php?/kpi/reports/67
http://mydomain.com/index.php?/kpi/reports/67/overview/2013-02-01/2013-02-28
The number 67 and the dates can all change in the URL's above hence the user of regular expressions below.
I have tested the regular expressions and they seem to match the URL's fine. However, the htaccess just seems to redirect it to https:// anyway.
My .htaccess file is as follows...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Disallow access to system dir
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Disallow access to application dir
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Force https when not on overview report
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/index\.php\?/kpi/reports/?([0-9]+)$
RewriteCond %{REQUEST_URI} !^/index\.php\?/kpi/reports/?([0-9]+)/overview/?([0-9]+)-?([0-9]+)-?([0-9]+)/?([0-9]+)-?([0-9]+)-?([0-9]+)$
RewriteCond %{REQUEST_URI} !^/kpi/reports/?([0-9]+)$
RewriteCond %{REQUEST_URI} !^/kpi/reports/?([0-9]+)/overview/?([0-9]+)-?([0-9]+)-?([0-9]+)/?([0-9]+)-?([0-9]+)-?([0-9]+)$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=302,L]
#If not a valid file, redirect request through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Any help would be greatly appreciated!
Maybe this will do what you need:
#Force https when not on overview report
RewriteCond %{HTTPS} off
RewriteCond %{QUERY_STRING} !kpi/reports/[0-9]+/?$ [NC]
RewriteCond %{QUERY_STRING} !kpi/reports/[0-9]+/overview/[^/]+/[^/]+/? [NC]
RewriteCond %{REQUEST_URI} !kpi/reports/[0-9]+/?$ [NC]
RewriteCond %{REQUEST_URI} !kpi/reports/[0-9]+/overview/[^/]+/[^/]+/? [NC]
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=302,L]
#If not a valid file, redirect request through index.php
Replace all lines between the comments.
I have 2 domain pointing to same directory, Now I want to redirect some URLs to one specific domain and rest should be on main domain.
I have one domain www.xyz.com this is main domain site will be open with this domain, from this domain I want to redirect specific URLs to different domain so if someone open www.xyz.com/a/theatre then it should redirect to www.abc.com/a/theatre. And now from same this new domain if someone click on URL which don't have "/a/theatre" in URL then it should redirect back to main domain. So if someone open www.abc.com/a/classes then it should redirect to www.xyz.com/a/classes
I have used bellow rules but not working,
RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]
RewriteCond %{REQUEST_URI} ^/a/theatre$
RewriteRule (.*)$ http://www.abc.com/a/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]
RewriteCond %{REQUEST_URI} !^/a/theatre
RewriteRule (.*)$ http://www.xyz.com/a/$1 [NC,L,R=301]
Any help is appreciated.
Thanks!
Here is all code from my htaccess, I have installed Joomla on this domain.
Options -Indexes
RewriteEngine on
RewriteBase /seo
RewriteCond %{HTTP_HOST} ^www.mcleancenter.org$ [NC]
RewriteCond %{REQUEST_URI} ^/seo/alden-theatre$
RewriteRule ^/?seo/(.*)$ http://www.aldentheatre.org/seo/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.aldentheatre.org$ [NC]
RewriteCond %{REQUEST_URI} !^/seo/alden-theatre
RewriteRule ^/?seo/(.*)$ http://www.mcleancenter.org/seo/$1 [NC,L,R=301]
########## Begin - Joomla! core SEF Section
#
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
You need to match out the leading /a/ by adding a ^/?a/ to the front of the regex in the rules.
RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]
RewriteCond %{REQUEST_URI} ^/a/theatre$
RewriteRule ^/?a/(.*)$ http://www.abc.com/a/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]
RewriteCond %{REQUEST_URI} !^/a/theatre
RewriteRule ^/?a/(.*)$ http://www.xyz.com/a/$1 [NC,L,R=301]