Why does mywebsite.com/page work, but mywebsite.com/page/ does not? We have an htaccess entry that removes the .php ending of files, for example “mywebsite.com/new.php” can be accessed simply as “mywebsite.com/new”. However, if a forward slash is added (and this seems to happen with some search engines adding it or browsers for some reason) then our 404 error page is shown. Any ideas? Many thanks!
Here are all the rewriterules in the .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9\-_]+)/?$ $1.php [NC,L]
rewriteCond %{HTTP_HOST} ^mywebsite.cz [NC]
rewriteRule ^(.*)$ http://www.mywebsite.cz/$1 [R=301,L]
rewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
rewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$
RewriteRule ^cs$ "http\:\/\/www\.mywebsite\.com\/index_cz\.php" [R=301,L]
RewriteCond %{HTTP_HOST} ([^.]+)\.mywebsite.com [NC]
RewriteCond %{HTTP:Accept-Language} (cs) [NC]
RewriteRule ^$ http://www.mywebsite.cz [L,R=301]
RewriteCond %{HTTP_HOST} ([^.]+)\.mywebsite.cz [NC]
RewriteCond %{HTTP:Accept-Language} (cs) [NC]
RewriteRule ^$ /index_cz [L,R=301]
RewriteCond %{HTTP_HOST} ^www.mywebsite\.com
RewriteRule ^([0-9]+)/?$ project.php?id=$1 [NC,L] # Handle project requests
RewriteCond %{HTTP_HOST} ^www.mywebsite\.cz
RewriteRule ^([0-9]+)/?$ project_cz.php?id=$1 [NC,L] # Handle project requests
You can try this:
also, you have to change all your , , to point to the root of the folder. eg:
will become: