I have a website that has 10 domain pointers they all point to the master-domain. I use this code in the .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !masterdomain.com$ [NC]
RewriteRule ^(.*)$ https://masterdomain.com/$1 [L,R=301] [R,L]
It works but I want https://masterdomain.com/administrator to point to https://licencepointerdomain.com/administrator/*
I tried :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ! masterdomain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/administrator/?$ [NC]
RewriteRule ^(.*)$ https://masterdomain.com/$1 [L,R=301] [R,L]
what am I doing wrong here?
Related
I would like redirect http://example.com/index.php?a=music to http://example.com/music (where the number is a variable/dynamic). My site is http : / / example . com
I added the following line to my mod-rewrite rules in my .htaccess file:
RewriteRule ^index\.php$/?/a/=(.*)$ http://example.com/index.php?a=$1 [L,R=301]
However, it doesn't seem to work. I know I'm doing something wrong, I'm just not sure how to fix it. Any help is appreciated.
Best,
Jeff
Edited:
Thanks Tom,
This is what I have:
Rewritecond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
This should work:
RewriteRule ^(.*)$ /index.php?a=$1 [L]
My SSL only covers swellnomore.com, not www.swellnomore.com.
I get a security error when i type https://www.swellnomore.com. Can this be fixed (forwarded to https://swellnomore.com ?
I had tried putting the following to htacess but did not helped too
# Override GoDaddy defaults that inhibit URL rewriting
Options -MultiViews
rewriteEngine On
# Rewrite URLs to remove www from domain name
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Before putting the above , htaccess looked like this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteEngine On
RewriteBase /
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^swellnomore.com$
RewriteRule ^/?$ "https\:\/\/swellnomore\.com\/" [R=301,L]
P.S , I had already changed the site domain to
https://swellnomore.com in wp dashboard > general settings.
If you rewrite the domain , you should rewrite to https not to http
Try this rewrite rule:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
whole htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# END WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Yes, it is possible. You just have to put this .htaccess in your root folder :
RewriteEngine On
RewriteBase /
RewriteRule ^/?$ http://sub.domain.com/this [L]
try this javascript
<script type='text/javascript'>
if(history.replaceState) history.replaceState({}, "", "/");
</script>
Note : where / is the path u want to show.
it shows the url like mysite.com no matter which link i have clicked. but i have a problem with this code while reloading the page the complete url with query string blink into address bar.
Update
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Example: http://www.addondomain.com/projects/a/gallery/4/2 -> http://addondomain.com/projects/a/gallery/4/2
Maybe this will help you:
Add this to your .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
I am redirecting an entire website, with a few exceptions. I have the following rules and conditions in place:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} !^loans\.myoldwebsite\.com$ [NC]
#RewriteCond %{HTTP_HOST} !^client\.myoldwebsite\.com$ [NC]
#RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^(client|loans)\.myoldwebsite\.com$ [NC]
RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,NE,R=302]
But I also need to make sure that http://www.myoldwebsite.com/getLead.php is ignored as well, so it doesn't get redirected.
You can have multiple RewriteConds:
RewriteCond %{HTTP_HOST} !^(client|loans)\.myoldwebsite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/getLead.php$
RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,NE,R=302]
I have a wildcard subdomain *.domain.com assigned to public_html/.
I want to do like this:
For example, /folder1/index.php is based on state name(?state=statename).
For the /folder1/folder2/index.php, it will be based on unique name(?name=uniquename).
So, www.domain.com/folder1/index.php?state=statename will be statename.domain.com
and www.domain.com/folder1/folder2/index.php?name=uniquename will be uniquename.domain.com
This is my code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folder1/index\.php\?state=([^\s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folder1/folder2/index\.php\?name=([^\s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]
The problem is it redirect back to public_html directory. Is there any problem with the code?
Old Code
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^$ /index [L]
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]
RewriteRule ^(index)/?$ /$1.php?name=%2 [L,NC,QSA]
Code explanation : Whenever user enter uniquename.domain.com, it will automatically go to www.domain.com/index.php?name=uniquename and the uniquename.domain.com in url bar would not change.
The differences for the new problem is there are different state directory and the domain would be state1.uniquename.domain.com. The 'state1.uniquename.domain.com' in the url bar should not change too.
Based on your comments. Make sure DOCUMENT_ROOT for www.domain.com, state1.domain.com, state2.domain.com is public_html
Try this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folder1/index\.php\?state=([^\s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folder1/folder2/index\.php\?name=([^\s&]+) [NC]
RewriteRule ^ http://%1.domain.com/? [R=301,L]
RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)\.domain\.com$ [NC]
RewriteRule ^ /state/%1/client/index.php?name=%2&page=%{REQUEST_URI} [L,NC]
Simplified Question
I changed domain.com/folder/client.php?id=1 to 1.domain.com with this .htaccess code
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]
RewriteRule ^$ /client.php?id=%2 [QSA,NC]
Now I want to change domain.com/folder/about.php?id=1 to 1.domain.com/about.
Is it possible ? or is there any other ways to do this?
Thank you :D
Old Question
In my directory, I have 2 pages (client.php, about.php). I've already set a wildcard subdomain to the page directory and changed domain.com/folder/client.php?id=1 to 1.domain.com. This is my .htaccess code :
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]
RewriteRule ^$ /client.php?id=%2 [QSA,NC]
Now, I need to add another page. So, in client.php page, there's a button to go to about.php page in the same directory. I tried 1.domain.com/about.php and it's not working.
Do I have to create another line of RewriteCond ? or is there any other ways to do this?
Thank you very much :D
Updated Code without working id
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/about [NC]
RewriteRule ^$ /client.php?id=%2 [QSA,NC]
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?([^.]+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/about [NC]
RewriteCond %{REQUEST_URI} !about\.php [NC]
RewriteRule . /about.php?id=%1 [L,QSA]
**The code resolved the text in url box. Let's say id=1. Now it's showing 1.domain.com/about.
the php code : `$_GET["id"]` is not specified.**
Thanks to faa for the edit :D
The Full Solution
Refer Using mod-Rewrite with 5 pages (wildcard sub-domain)
You may try this:
Options +FollowSymLinks
RewriteEngine on
## This is the actual rule-set that works as it is according to the OP
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]
# Added to exclude folder `/about`
RewriteCond %{REQUEST_URI} !^/about [NC]
RewriteRule ^$ /client.php?id=%2 [L,QSA,NC]
## This is the additional rule set
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?([^.]+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/about [NC]
RewriteCond %{REQUEST_URI} !about\.php [NC]
RewriteRule . http://domain.com/folder/about.php?id=%1 [L,QSA]
Maps silently
http://N.domain.com/about with or without trailing slash
To:
http://domain.com/folder/about.php?id=N
For permanent and visible redirection, replace [L,QSA] with [L,R=301,QSA]