0

Please help me with redirect in .htaccess
I need redirect to url with trailing slash

www.example.cz/about--> www.example.cz/about/
www.example.cz/index.php?path=about --> www.example.cz/about/

and last
www.example.cz/index.php --> www.example.cz

#MY .htaccess
<FilesMatch "\.phtml$">
  Order Deny,Allow
  Deny From All
</FilesMatch>

ErrorDocument 404 /404/

RewriteEngine On 
RewriteBase /

RewriteCond %{HTTP_HOST} ^example.cz$
RewriteRule (.*) http://www.example.cz/$1 [R=301,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?path=$1 [L,QSA]
marefly
  • 37
  • 1
  • 7

1 Answers1

0

I solved trailing slash and index.php duplicates :)

<FilesMatch "\.phtml$">
  Order Deny,Allow
  Deny From All
</FilesMatch>

ErrorDocument 404 /404/

RewriteEngine On 
RewriteBase /

RewriteCond %{HTTP_HOST} ^example\.cz$
RewriteRule (.*) http://www.example.cz/$1 [R=301,L]
RewriteRule ^index.php$ http://example.cz/$1 [R=301,L]    

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /?path=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]

Now .htaccess doing

www.example.cz/index.php --> www.example.cz/
www.example.cz/about--> www.example.cz/about/
example.cz --> www.example.cz

Next, I need to solve

www.example.cz/?path=about--> www.example.cz/about/
www.example.cz/about/ --> wwww.example.cz
marefly
  • 37
  • 1
  • 7