Cannot get rewrite to work extension

I cannot seem to get a rewrite to work after trying about 4-5 different ways.

Is there a specific area to insert it?

code that is unnecessary? that Frontpage stuff

I want it to simply to 2 rewrites.

remove the file extension “.php” and if someone types just that it changes to which already works but I cannot make both work.

both should be perm 301’s

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
order deny,allow
deny from all
AuthUserFile /home/main/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/main/public_html/_vti_pvt/service.grp

ErrorDocument 404

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\\.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

order allow,deny
deny from
allow from all

<IfModule mod_expires.c>

# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

# My favicon
ExpiresByType image/x-icon "access plus 1 year"

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

ExpiresByType text/css "access 1 month"

# Javascript
ExpiresByType application/javascript "access plus 1 year"


Hi lukkas!

Apache or IIS?

Comments on your .htaccess code:

Okay, I’m commented out.

I did consider whether you should also check to see whether the %{REQUEST_FILENAME} is a file
before making the redirection to %{REQUEST_URI}.php (to prevent looping) but, IMHO, you’re not
likely to be using {filename}.php.php so that would be a repetitive test only to check your file naming
convention, i.e., another waste of time/resources.

I don’t understand WHY your mod_rewrite code does not work UNLESS you’re using IIS and not Apache OR
your password protection is forbidding website access (you didn’t comment on that so I’ll assume that’s
correct and you’re using IIS which does not perfectly duplicate Apache’s mod_rewrite).



I don’t have access to the server and need it there to block some spammer. I know there’s other ways but so far it has worked.

From tech support [ “The sever in which your website is hosted is having LiteSpeed webserver. LiteSpeed Web Server’s rewrite engine is fully compatible with Apache mod_rewrite so there is no need to change rewrite directives in LiteSpeed. The rewrite engine is highly optimized and increases speed over Apache’s rewrite engine, especially for rewrite directives in a .htaccess file.”]

I had already omitted the 2nd “RewriteEngine on” rule too and experienced no change.

RewriteRule . %{REQUEST_URI}.php [L]

(note that this requires at least one character so you don’t ask for .php as the file)


RewriteRule .?{REQUEST_URI} [L] - no longer a R=301 ??? I didn’t want 2 of the same file indexed. Will this ensures it is not in making two of the same file?,,,,

  • if Module –>

I was told to just copy and paste that in so it speeds up the website - browser caching. Google site speed checks. I don’t want the same person using resources over & over again. it is recommended

Hi lukkas,

My responses are indented with