I've recently installed WordPress. Since I want it running from the root directory and like some nice looking permalinks i've added a new section to my htaccess file on the httpdocs of my server.
Since this time the redirect for other domains isn't working anymore.
This is the current code:
Options +FollowSymLinks
RewriteEngine On
#Redirect to other DOMAINS
#----------------
RewriteCond %{HTTP_HOST} (www\.)?example1.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/e1/.*$
RewriteRule ^(.*)$ /e1/$1
RewriteCond %{HTTP_HOST} (www\.)?example2.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/SR/.*$
RewriteRule ^(.*)$ /SR/$1
#ALTERNATE DOMAINS
# ---------------
RewriteCond %{HTTP_HOST} ^www.gw.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^gw.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.cb.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cb.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
The WordPress site works as it should. Alternate domains works as well. However, the other two sites are totally out of the running, now displaying the main wordpress website.
If I change RewriteRule . /wordpress/index.php [L] to RewriteRule . /index.php [L] it will return an internal server error.
Anybody got a clue what's the mistake?
adding the flags
[R=301,L]
to the first two rules worked!
Related
For a main domain (.nl) everything is forced over https and www.
However there is a small bug with parked domain .be
when accessed like https://domain.be/example the www. is not added.
In all other cases it is working.
.htaccess i have so far is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteRule ^(.*)$ https://www\.%1/$1 [R=301,L]
</IfModule>
Any ideas would be welcome!
Might want to check this
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I am trying to forward my website to a new domain and want all old pages to be also redirected.
I have done the following.
In my registrar, I have forwarded my old domain to the new domain.
On my old website server, I have added the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com$ [NC]
RewriteRule ^ http://new_domain.net%{REQUEST_URI} [NE,R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</IfModule>
# END WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old_domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old_domain.com [NC]
RewriteRule ^(.*)$ http://new_domain.net/$1 [L,R=301,NC]
The main site is being redirected correctly. However, when I click on old_domain.com/old_post, I get a blank page.
How can I fix this?
Thank you
I have a wordpress website in /subfolder.
In the root, there is a folder called /reports/
I need to rewrite url so /reports/ becomes /reports/index.php but wordpress is changing path to be /reports/. (and I get page not found)
This is my .htaccess:
RewriteEngine on
RewriteBase /
# Only apply to URLs that aren't already under /wordpress2.
RewriteCond %{REQUEST_URI} !^/wordpress2/
# Rewrite all those to insert /wordpress2.
RewriteRule ^(.*)$ /wordpress2/$1
# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?website.com.au$
RewriteRule ^(/)?$ wordpress2/ [L]
RewriteCond %{HTTP_HOST} ^/reports$ [NC]
RewriteRule ^(.*)$ /reports/index.php/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^freeloancalculator.com.au/reports$ [OR]
RewriteCond %{HTTP_HOST} ^www\.reeloancalculator\.com\.au/reports$
RewriteRule ^/?$ "http\:\/\/reeloancalculator\.com\.au/reports/index.php\/" [R=301,L]
I hadn't tried this, but I think this will help you..
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/index.php /reports=$1/ [NC]
By adding ./ /index.php, it fixes the issue
# 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
Ok. I'm desperate.
Basically when i add the #Force https lines below it's then sending my shop.mydomain.com/wp-admin to mydomain.com/wp-admin Aaaaaah.
My wordpress shop site lives inside the main domain folder (inside the other wordpress site) i.e. public_html/mydomain(wordpress install)/shop(wordpress install)
I have a Wildcard SSL installed on the www.mydomain.com (which handles 1st level subdomains). The SSL part seems to be working fine.
Here is the .htaccess inside the folder /shop:
#Send www to https
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.shop.mydomain.com$ [NC]
RewriteRule ^(.*)$ https://shop.mydomain.com/$1 [R=301,L]
#Force Https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
etc etc
# END WordPress
And inside the main domain folder public_html/mydomain:
#.htaccess WildCard SSL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteRule ^(/)?$ shop/index.php [L]
# BEGIN WordPress
etc etc
# END WordPress
Would be grateful for any advice. =>
Place the following in the .htaccess for the domain
# .htaccess WildCard SSL + wordpress + subdomain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/)?$ shop/index.php [L]
# BEGIN WordPress for main domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am trying to redirect my whole site to non-www
here is the htaccess code I am using
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]
any ideas
I think your rules need to between the module tags.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
Here is what you need to add to your .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
However, if you are working with Wordpress as the engine that powers your entire site, just update the permalink structure and all internal settings with your domain name in it to remove the www.
EDIT:
I thought that was different when I wrote the answer Sorry. Try moving your non www rule to the top...
# no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301s,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AGAIN keep in mind if Wordpress is set to produce links with a www then nothing will stop it from reverting everything back to having a www even with a correct rewrite rule.
More Wordpress details:
Check the settings in wp/wp-admin/options-general.php ...
Be sure to remove the www in WordPress address (URL)
Be sure to remove the www in Blog address (URL)
AND then update your premalink structure in wp-admin/options-permalink.php so the changes are reflected.
After all that is said and done, be sure Wordpress did not overwrite new code in your .htaccess file.
Hi I think you need to adjust your script as follows for the rewriting to work:
Options +FollowSymlinks
RewriteEngine on
I believe that the follow symlinks absolutely has to be included for url rewriting to work properly.
More advice on mod_rewrite here:
http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html
Rob
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTP_HOST} ^([^.]+)\.akorra\.com$ [NC]
RewriteRule ^(.*)$ http://akorra.com/$1 [R=301,L]
# WordPres
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
This should work
I suggest to use this piece of code for removing www from your website:
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
it's more generic.
and in your example it's best to use this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>