I have below code inside my .htaccess which is placed inside my wordpress blog located under subdomain. Now I moved my blog under subfolder and I placed 301 redirects from subdomain but when I visit pages at blog.domain.com I get 500 internal server error instead of getting 301 redirects to http://domain.com/blog/
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
RewriteCond %{HTTP_HOST} ^blog\.stream-tek\.com
RewriteRule ^(.*)$ http://www.stream-tek.com/blog/$1 [R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Now when I remove code between:
# BEGIN WordPress
# END WordPress
I get 301 redirects from subdomain pages, but when I return it back its not working. I need that part of code since wordpress clean urls wont work without that.
What is the problem with above htaccess file since I am not expert with that.
Thanks for help.
Problem is the WP stuff take full control even before your redirect gets a chance to kick in.
Change the order of rules.
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
RewriteEngine On
RewriteBase /blog/
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^blog\.stream-tek\.com$ [NC]
RewriteRule ^ http://www.stream-tek.com/blog%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Related
I transferred my website from olddomain.de to newdomain.de and wanted to redirect every page of the old website to the new website (e.g. olddomain.de/contact -> newdomain.de/contact). When I enter the main page of the old website in the browser, I am redirected correctly but all other pages are not redirected.
I tried a lot of different redirect options and currently this one is implemented (the first IfModule already existed):
# 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>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.de/$1 [R=301,L]
</IfModule>
# END WordPress
Does anyone know how to correct the .htaccess file, so that all pages of the website are being redirected?
EDIT:
I managed to get all sites redirected by putting some code at the top of the IfModule like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.de$
RewriteRule (.*)$ http://newdomain.de/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Since this is working fine now, I wanted to change the address in the google search console but it says that the 301 redirection is not working. Does anyone have any suggestions here?
since your old site is not serving a WordPress instance anymore try removing the first part of your .htaccess file (you don't need it and may be causing the issue.
So let it just like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.de/$1 [R=301,L]
</IfModule>
Pages on our WordPress site are not automatically redirecting to the HTTPS version even though we have set the site url and home url to use HTTPS.
This is the code we have at the top of our wp-config.php file:
define('WP_HOME','https://webwisemedia.co.uk');
define('WP_SITEURL','https://webwisemedia.co.uk');
define('FORCE_SSL_ADMIN', true);
Our .htaccess file looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If you visit a page on our site, like http://webwisemedia.co.uk/web-wise-in-the-press/, it doesn't redirect to the HTTPS version.
Any ideas why?
You mixed up the Wordpress part of .htaccess and that is why it isn't working. That part is changed every time you update, for example, permalinks. Your .htaccess should look like this:
# Rewrite HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
# 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
This leaves the Wordpress part intact and it forces to use https. From now on if you change anything in .htaccess do it below the Wordpress part.
I "inherited" a website at the department I am working at that is hosted on a machine we don't have root access to. I managed to force https with the .htaccess file, but I was unable to add wordpress permalinks to it also. The combinations I tried all ended up pointing every link to the front page.
This is the .htaccess we have now (the wordpress website is in a subdirectory):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^familydogproject.elte.hu$
RewriteCond %{REQUEST_URI} !wordpress/
RewriteRule ^ https://%{HTTP_HOST}/wordpress/%{REQUEST_URI} [L,R=301]
And this is the example wordpress gave for the permalinks:
# 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
Does anybody have any idea how to combine them?
We had several domains parked on top of our main website. This was a normal HTML website and we used the following redirect so that the domain would 301 redirect to the proper url to avoid getting dinged by Google.
rewriteCond %{HTTP_HOST} ^ourmainsiteurl\.com$
rewriteRule ^.*$ http://www.ourmainsiteurl.com%{REQUEST_URI} [R=permanent,L]
So the above htaccess code just rewrites the url to www.ourmainsiteurl.com, which is what we want.
Now here's the problem... we installed Wordpress and it has the following default htaccess code:
# 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
I tried to add my redirect code in but that broke Wordpress. Can anyone tell me what I need to use to make this work?
Simply put I want all the parked domains (ie: parkedurl1.com, parkedurl2.com, etc) to be redirected to www.ourmainsiteurl.com with the htaccess file.
Make sure the redirect is before any wordpress rules:
rewriteCond %{HTTP_HOST} ^ourmainsiteurl\.com$ [NC]
rewriteRule ^.*$ http://www.ourmainsiteurl.com%{REQUEST_URI} [R=permanent,L]
# 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
If it's still not working, check to see if wordpress has something turned on that is redirecting, or adding/removing the "www" from the hostname.
I am looking to write 301 redirects for a site. I would like the redirect to go from http://www.ehlconsulting.com/our-services-basic-services/ to http://www.ehlconsulitng.com/services/.
My .htaccess file is as follow
RewriteEngine On
RewriteCond %{HTTP_HOST} ^ehlconsulting.com
RewriteRule (.*) http://www.ehlconsulting.com/$1 [R=301,L]
# 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
Redirect 301 /our-services-basic-services/ http://www.ehlconsulting.com/services/
When you go to the old URL it doens't redirect. Instead it shows "Bots get the naked version"
You probably don't want to use Redirect and want to move the actual redirect above your wordpress rules:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^ehlconsulting.com
RewriteRule (.*) http://www.ehlconsulting.com/$1 [R=301,L]
RewriteRule ^our-services-basic-services/(.*)$ http://www.ehlconsulting.com/services/$1 [L,R=301]
# 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
The "Bots get the naked version" thing doesn't have to do with your rules, it's probably WPEngine or something that's doing that by default, and you might be able to override that by using a ErrorDocument 404 in your htaccess file. The problem with using a Redirect along with wordpress' RewriteRule's is that they conflict with each other.