htaccess, directadmin vhost and wordpress - wordpress

i have task to create connect to wordpress by default https with wwww in url
#Require SSL
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# 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
but this configuration dont working. Maybe httpd.conf or directadmin.confg have some flag/configuration for this?
Thanks.

Related

.htaccess issue, folder in wordpress?

I have a folder called /mf/ that is not related to the wordpress install but it is in the same root folder. When I visit the folder path (www.domain.com/mf) it gives me a 500 error. I know that this is an .htaccess issue.
I've modded my root .htaccess to do the below code but it still does not work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/mf/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# 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
Any advice on how to fix this .htaccess issue?
in your "mf" folder create a .htaccess file and there put all the configuration that nedded, and in the main folder-wordpress put only the wordpress part.
in th "mf" change the RewriteBase too.
main-wordpress
# 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 mf folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mf/
RewriteCond %{REQUEST_URI} ^/mf/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

My https website is redirecting to my old http website

a while ago i made a copy of my wordpress website and restore it on a ssl/https verficated account and since that, my new site have been redirecting to http.
I've tried with the htaccess code and it doesn´t work. I'll paste my code below:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://voladurascontroladas.com/$1 [R,L]
# BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.20]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTPS_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# 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

Wordpress RewriteRule is not working

This is my current .htaccess file content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I want to change:
http://example.com/search/?location=&radius_key=sydney/&keyword=&geolocation=
to:
http://example.com/massage/sydney/
I have modified script as below but it's not changing my URL. Could you please guide me. Any kind of response to fix this problem is highly appreciated. Thanks
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/massage/(.*)$ /search/? location=&radius_key=$1&keyword=&geolocation=
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If you want the URL displayed in the browser address bar to change, you have to activate the "R" flag in modrewrite, which activate the Redirection.
So you'll write something like
RewriteRule /search/\?.*location=([a-z0-9_.-]+)&.* geolocation=$1 [R=301,L]
I suggest also to split the configuration in two part, in order to keep the original Wordpress configuration unmodified.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /search/\?.*location=([a-z0-9_.-]+)&.* geolocation=$1 [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You need to change up your rules a little bit. This should allow you to use the new URL and also your wordpress rules.
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{THE_REQUEST} ^GET\ /search/\?location=&radius_key=([^\ &]+)&keyword=&geolocation=
RewriteRule ^ /massage/%1? [R=301,L]
RewriteRule ^massage/([^/]+)/?$ /search/?location=&radius_key=$1&keyword=&geolocation= [L]
RewriteRule ^index\.php$ - [L]
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Let me know how this works for you.

https to http redirect not working

I have a Wordpress installation where some https URIs have been picked up by Google - the site does not have an SSL certificate and I don't want one. As a result I'm trying to redirect from https to http, but it's not working. All I'm seeing in Google Chrome is the "Your connection is not private" message.
I've put the redirect at the top of the htaccess file and I can't work out why the url isn't redirecting to http so that the message doesn't appear? I've also tried it on other devices and browsers. Any ideas why the redirect isn't working?
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
RemoveHandler .php
AddType application/php5-fcgi php
Action application/php5-fcgi /cgi-bin/php5fcgi.fcgi
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteBase /bevanevemy.co.uk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#RewriteRule . /bevanevemy.co.uk/index.php [L]
</IfModule>
# END WordPress
You forgot your R,L modifiers ( Redirect, Last) this way, it will go to the url and stop processing rules.
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RemoveHandler .php
AddType application/php5-fcgi php
Action application/php5-fcgi /cgi-bin/php5fcgi.fcgi
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteBase /bevanevemy.co.uk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#RewriteRule . /bevanevemy.co.uk/index.php [L]
</IfModule>
# END WordPress
EDIT also, apache uses different file for ssl config. Maybe that is the problem
https://stackoverflow.com/a/8760123/3617531
Edit Your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

.htaccess rules to have wordpress in root and cakephp in subfolder

i installed wordpress in the root directory of my FTP, and then in a subfolder I install cakephp, however I have a problem with htaccess.
www/
.htacess
(wordpress)
/folderCakephp/
.htacess
(cakephp)
Wordpress 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
Cakephp root htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Cakephp app/ htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Cakephp app/webroot/ htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
the problem is that when I go on www.domain.com/folderCakephp/ I have a Wordpress 404
In the directory where WordPress is installed, i editing the .htaccess file and i have add the following line. (CakePHP subdirectory will be called "cake")
Wordpress .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^cake/(.*)$ /cake/$1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
/cake .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cake
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
That’s it. You’re good to go.
Visiting example.com in the browser will open your WordPress website, while example.com/cake/, depending on how you configured it, will open your CakePHP app.
I believe the issue is the last line in your WordPress rewrites
RewriteRule . /index.php [L]
This rewrites everthing that isn't picked up by another rule to WordPress. I think you want to change this to match everything but the cakePHP folder using a negative match. I have not tested this, but it should be something like
RewriteRule (?<!folderCakephp). /index.php [L]

Resources