htaccess为静态php文件

I am struggling to get my .htaccess file working properly on my GoDaddy web hosting.

I want my URL's to be like:

www.way360group.com/about-us/ -> about-us.php www.way360group.com/latest-projects/ -> latest-projects.php

and so on...

Here's my current .htaccess code

## EXPIRES CACHING ##
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/jpg "access 1 year"
        ExpiresByType image/jpeg "access 1 year"
        ExpiresByType image/gif "access 1 year"
        ExpiresByType image/png "access 1 year"
        ExpiresByType text/css "access 1 month"
        ExpiresByType text/html "access 1 month"
        ExpiresByType application/pdf "access 1 month"
        ExpiresByType text/x-javascript "access 1 month"
        ExpiresByType application/x-shockwave-flash "access 1 month"
        ExpiresByType image/x-icon "access 1 year"
        ExpiresDefault "access 1 month"
    </IfModule>
## EXPIRES CACHING ##


# force ssl
RewriteEngine On
        RewriteCond %{SERVER_PORT} ^80$
        RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]


# Redirect from http://www to http://
    RewriteEngine On
        RewriteBase /
        RewriteCond ${HTTPS} off
        RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        RewriteRule ^(.*)$ https://%1/$1 [R=301,L]


# Rewrite URLs
    RewriteEngine On
        RewriteRule   ^contact?$        contact.php 
    
        RewriteRule   ^what-is-corporate-social-responsibility?$        what-is-corporate-social-responsibility.php 
    
        RewriteRule   ^about-us?$       about-us.php 
    
        RewriteRule   ^latest-projects?$        latest-projects.php 
    
        RewriteRule   ^join-our-newsletter?$        join-our-newsletter.php 

I've digged many different posts but couldn't work out a solution.

Thanks in advance!

</div>

The positioning in .htaccess is really important. Since you have [L] flag, that marks it as last, so if you get any URL it will redirect to https:// and as the [L] flag the .htaccess won't go further, since the rule is valid and it will stop there.

If you are using [L] flag make sure you put those rules last, so any other rule can be checked before that one.

Also you might be lacking a bit of conditions for the rules, since your only condition is that the HTTPS is off.

On the other hand the rest of the rules you wrote seem alright.

For anything else you can look at this site for more insight here

Here's an example of one of the .htaccess'es that I use

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

        # force ssl
        RewriteEngine On
                RewriteCond %{SERVER_PORT} ^80$
                RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    # Redirect from http://www to http://
    RewriteEngine On
                RewriteBase /
                RewriteCond ${HTTPS} off
                RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
                RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Hope that will clear it up a little (of what I was talking about earlier in the post). Also when you are coding try to leave comments behind (you can see my # comments in .htaccess), it will be helpful later on when you revisit the code after some time, so you know what's where or if someone new comes to work with you, will be much easier for them.