Implement server-side redirects (301) from old 
Auteur : Nektarios K.
Visité 262,
Followers 1,
Partagé 0
Hi there,
Question: How can to Implement server-side redirects (301) from old
Before
https://www.pamsmaritime.com/cargo.php
After
https://www.pamsmaritime.com/cargo/
I did, but only for the home page. How can I make it for all the pages?
Please advise.
Nek
Posté le

Auteur
I use this in .htaccess, but show Page not found 404...
# remove .php; use THE_REQUEST to prevent infinite loops RewriteCond %{HTTP_HOST} ^www\.pamsmaritime\.com RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP RewriteRule (.*)\.php$ $1 [R=301]
# remove index RewriteRule (.*)index$ $1 [R=301]
# remove slash if not directory RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /$ RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L]
Any solution?
Nek
Here is the answer from Google AI, although I don't know if the answer is correct.
----- Google AI -----
.htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
Important: After inserting these rules, you must adjust the links in your HTML code, i.e. change ...
href="page-abc.php" >> href="page-abc"
-----
If it doesn't work, then wait for the experts.
Auteur
Dear Daniel,
Thanks for your reply and instructions.
I will try it, and I will let you know.
Nek