1
votes

I need one 301 redirect on Wordpress site not twice

i need https://www.example.com/sports/test/index.php -> https://www.example.com/sports/test

i have a twice 301 redirect https://www.example.com/sports/test/index.php -> https://www.example.com/sports/test/ -> https://www.example.com/sports/test

I have a site on Wordpress with structure http://www.example.com then i bougth ssl-sertificate and my structure now https://www.example.com
Settings:
1) Permalinks -> custom structure https://www.example.com/%category%/%postname%/
2) Category prefix -> . (just dot)
3) .htacess (with Wordpress original rules for urls)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#use many recomendation
#-------like this
#RewriteCond %{HTTP_HOST} ^example\.com [NC]
#RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
#-------end like this

#-------like this
#RewriteEngine on
#RewriteCond %{HTTP_HOST} !^www\. [OR]
#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
#RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R=301] 
#-------end like this

RewriteRule ^index\.php$ - [L]   #remove index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

All it works but with twice 301 redirects or many loop redirects, i need once redirect on WP site. Thank u for helps me )

2

2 Answers

0
votes

Try to change permalink structure and resave it.

If .htaccess is wordpress default you should haven't problem.

For https i use this plugin https://it.wordpress.org/plugins/really-simple-ssl/ is very simple to use and efficient.

Let me know

0
votes

After RewriteEngine On and before RewriteBase / adding this lines:

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} " /(index\.php|([^?]*)/index\.php)"
RewriteRule ^ https://www.example.com/%2 [R=301,L,NE]

It works fine for me