Subdirectory doesnt work without slash ("/" symbol) - wordpress

haberimyok.com/tr doesnt work,
haberimyok.com/tr/ works.
.htaccess is in the /web/tr directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?haberimyok.com$
RewriteCond %{REQUEST_URI} !^/web/tr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/tr/$1
RewriteCond %{HTTP_HOST} ^(www.)?haberimyok.com$
RewriteRule ^(/)?$ index.php [L]
</IfModule>
Thank you.

Related

Domain redirirection to https issue

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

Hide the WordPress installation subfolder with htaccess

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.

htaccess wordpress redirect directory

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]

htaccess wordpress 301 redirect

I recently added SSL to my wordpress site and now if some goes to my http site, I would like to redirect them to my https site. I have tried the following below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
But got this error
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
What am I doing wrong?
Here is the code that you should use for enforcing https:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Try this :
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^http://\.(.*)
RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Combine 2 .htaccess Files

I have 2 .htaccess files that I need to merge together. One is generated by wordpress and the other is the existing .htaccess file for the site. The 2 files are as follows:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301]
RewriteRule ^postreview/$ /viewreview.php [NC,PT,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ ./template2.php
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off
# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
php_flag session.use_trans_sid off
2nd file generated by wordpress:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectcars/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projectcars/index.php [L]
</IfModule>
I've tried several ways to combine them, but I either get a redirect error or a internal server error.
Here's my fix:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^postreview(\/?)$ /viewreview.php [QSA,NC,PT,L]
RewriteRule ^projectcars/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^projectcars/(.*)$ /projectcars/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) template2.php [NC,L]
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
php_flag session.use_trans_sid off

Resources