I already have some url redirect rule in my root htaccess so after following the step to give wordpress its own directory everything work well apart that my old url redirection/rewrite don't work any more.
old htaccess
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule dailylife/(.*)\.html dailylife.php?d=$1
new one with wordpress directory
RewriteBase /news/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
RewriteRule dailylife/(.*)\.html dailylife.php?d=$1
any help most welcome
You need to have your old rules before wordpress' routing rules:
RewriteBase /news/
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule dailylife/(.*)\.html /dailylife.php?d=$1 [L]
RewriteBase /news/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
Related
I have an issue with my domain redirections.
It's wordpress and I want to redirect all non secure urls to secure
The problem that when typing in the addressbar: http://www.my-domain.com it redirects to https://www.www.my-domain.com
(It adds an extra www)
Here is my redirection part in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule (.*) https://www.%1/$1 [R=301,L]
</IfModule>
What am I doing wrong ?
This code is Work for me
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteOptions inherit
RewriteEngine on
Header set content-Security-Policy: upgrade-insecure-requests
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I've got my WordPress installed in /apache_installation/dir1/dir2/wp_dir/ and it's accessed through http://myIp/dir1/dir2/wp_dir/
I'd like the users to view only the url http://myIp/dir1/dir2/ but the files continue being served from the /wp_dir/ subfolder.
I've tried so many choices, all from stackoverflow, and all of them preceded of
php_value magic_quotes 0
php_flag magic_quotes off
php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2/$
RewriteRule !^wp_dir/ /wp_dir%{REQUEST_URI} [L]
or
RewriteRule ^$ wp_dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ wp_dir/$1
or
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+wp_dir/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^wp_dir/)^(.*)$ /dir1/dir2/wp_dir/$1 [L,NC,R=301]
or
RewriteRule ^/wp_dir/(.*)$ http://myIp/dir1/dir2/wp_dir/$1 [L,R=301]
or
RewriteCond %{THE_REQUEST} ^GET\ /wp_dir/
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2$
RewriteRule ^wp_dir/(.*) /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2$
RewriteRule !^wp_dir/ wp_dir%{REQUEST_URI} [L]
or
RewriteRule !^wp_dir/ /dir1/dir2/wp_dir%{REQUEST_URI} [L,NC]
or
RewriteCond %{REQUEST_URI} !^wp_dir/
RewriteRule ^(.*)$ wp_dir/$1 [L]
or
RewriteCond %{HTTP_HOST} ([^/]+)\.myIp.*
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule .* http://myIp/dir1/dir2/wp_dir/%2 [L]
or
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+wp_dir/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
or
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^wp_dir/)^(.*)$ /dir1/dir2/wp_dir/$1 [L,NC]
and followed by
ErrorDocument 404 /404page.php
Inside wp_dir, there's another htaccess (generated by wordpress) with the code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dir1/dir2/wp_dir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dir1/dir2/wp_dir/index.php [L]
</IfModule>
I've touched nothing in it.
None of the root htaccess choices work for me, everyone with different errors. Some of them gives a "Not found" error, other displays the core of the wordpress site but with the content of the 404 page.
I'm stuck at this point, as you can see I'm not used to this file.
It seems that your entire site is in the wordpress folder - what you could maybe do is copy all of the files inside the main folder, and paste them in the root folder - afterward deleting the wordpress folder.
Hi i am new to wordpress .I've changed my hosting .But the page loaded without css(if www.domain.com) .
Otherwise it shows an error(domain.com). I think the problem in htaccess file. Please help me to fix this error. Thanks
here is code in htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
Add a slash in the last line and try
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . /index.php [L]
We are trying to make a change of domain for a wordpress.
The blog is in a subfolder called "blog".
The old domain is
http://www.peluches-et-jouets-en-bois.fr/blog
We want all the pages of the blog to be redirected to :
http://www.peluchesetjouetsenbois.fr/blog
It does work for the home page of the blog, but as soon as we go to another page of the blog, then it doesn't work anymore.
Here is what we have so far.
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]
RewriteCond %{HTTP_HOST} ^(www\.)?peluches-et-jouets-en-bois.fr$
RewriteRule ^(.*)$ http://www.peluchesetjouetsenbois.fr/blog/$1 [L,R=301]
</IfModule>
# END Wo
If someone can help us on that, that would be great :)
Thanks a lot
Place redirection rule before existing WP rules:
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTP_HOST} ^(www\.)?peluches-et-jouets-en-bois\.fr$ [NC]
RewriteRule ^(.*)$ http://www.peluchesetjouetsenbois.fr/blog/$1 [L,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
My main domain is a Wordpress blog, and the .htaccess rewrite for it is as follows...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This works great, but I have a subdomain in that same directory, and am using this rewrite for it....
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^my\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/my/
RewriteRule ^(.*) /my/$1
That's for my wildcard SSL certificate. This works great, but if the location doesn't exist in the subdomain I get wordpress's error page. I need the wordpress rewrite to ignore the "my" subdomain. How can I do that?
I was thinking something like....
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^my\.domain\.com$
RewriteRule . /index.php [L]
</IfModule>
But that doesn't work, also tried this....
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^my\.domain\.com - [L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any ideas?
You should probably ignore the domain by adding a condition on the server name.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} !^my\.domain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Also, a thing I struggled with some time ago, try changing the htaccess of the subdomain to
RewriteBase /my
if "my" would be the directory it lives in.