I want to redirect all traffic request uri to homepage of my wordpress page.
I try override default wordpress, but cant get this to work any one can help in this ?
I try following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /wordpress/
RewriteBase /
<If "%{REQUEST_URI} != 'http://127.0.0.1/wordpress/'">
Redirect 301 / http://127.0.0.1/wordpress/
</if>
#RewriteRule (.*) http://127.0.0.1/wordpress/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
You can use this rule just below RewriteBase line:
RewriteCond %{THE_REQUEST} \s/+wordpress/\S [NC]
RewriteRule .+ /wordpress/ [L,R=301]
Related
I have the following .htaccess inside webroot directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/admin/)
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Then, inside public directory I have the following .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php?$1 [QSA,L]
# Force HTTPS
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Then, if I hit the following URL:
http://example.com/
The browser is redirected to:
https://example.com/public/
When site is loaded over HTTP (without forcing), this part is omitted.
Force https rule must be placed in root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^$ public/ [L]
RewriteCond %{REQUEST_URI} !^(/admin/)
RewriteRule (.*) public/$1 [L]
</IfModule>
Remove http->https rule from public/.htaccess and clear browser cahce to test this.
I have a bunch of domains that all go to the same site and need to be able to redirect domainalias.com/folder/name to website.com/folder/name.
I currently have the following htaccess which works as far as redirecting the root domain, but as soon as I go into a sub-directory or sub-page, it won't redirect:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# Redirect all domains to website.co.uk
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^website.co.uk$ [NC]
RewriteRule ^(.*)$ http://website.co.uk/$1 [L,R=301]
</IfModule>
So to confirm, I want people to be redirected from http://anydomainalias.co.uk/any/sub/folder to http://website.co.uk/any/sub/folder. As it's a WordPress site, I need this to work dynamically. I have 50-odd subdomains so want to avoid having a rule for each one as well (hence the !^website.co.uk rule).
Thanks.
Have redirect rule before default WP routing rule:
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all domains to website.co.uk
RewriteCond %{HTTP_HOST} !^website\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://website.co.uk/$1 [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
Make sure to test it after clearing your browser cache.
I have a wordpress site accessed like http://example.com/
but my client wants to have it accessed like http://www.example.com/
I am finding this code as a solution
# 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ www.domain.com/$1 [L,R=301]
But I am getting an error of redirect loop
Could you please advice me what am i doing wrong?
You're missing http:// from your www forcing rule. Also important is to have your www rule before other WP rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Also don't forget to change WP permalinks to have www in Site and Home URLs
You have an easy way to do this inside of wordpress:
Go to your wordpress dashboard and:
1) Select Settings
2) Select option General,
3) Add to your WordPress Address (URL) the www part
4) Add to your Site Address (URL) the www part
And done!
I'm trying to redirect all subpages of a page using .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^/news-and-events(.*)$ /news/$1 [R=301,L,NC]
The above doesn't seem to be working, what's the easiest way to do this in as few lines as possible?
My HTAccess:
# 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
RewriteRule ^news-and-events(.*)$ /news/$1 [R=301,L,NC]
Remove leading slash:
RewriteRule ^news-and-events(.*)$ /news/$1 [R=301,L,NC]
.htaccess is per directory directive and Apache strips the current directory path from RewriteRule URI pattern.
I'm trying to have my http page to https. The page I want to change is http://dtesolar.ca/estore
I wish I could have https instead of http. I already purchase the ssl certificate, I'm using HTTPS plugin for wordpress but it's not working, so I'm thinking to use the .htaccess file to do it, but not sure for the syntax.
Here's the default thing on htaccess file:
# 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
Please help!
Have your .htaccess like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# force HTTPS for store
RewriteCond %{HTTPS} off
RewriteRule ^estore/ https://%{HTTP_HOST}%{REQUEST_URI} [L,NC,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
PS: You will need to fix links for your JS, css and images on this https URL.