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 website.com that it changes to www.website.com 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
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName website.com
AuthUserFile /home/main/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/main/public_html/_vti_pvt/service.grp


ErrorDocument 404 http://www.website.com/404

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

RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.com
RewriteRule (.*) http://www.website.com/$1 [R=301,L]


order allow,deny
deny from
94.100.22.210
213.238.175.8
188.143.232.31
188.143.232.111
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"

# CSS
ExpiresByType text/css "access 1 month"

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

</IfModule>


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).

Regards,

DK

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)

and

RewriteRule .? http://www.website.com%{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?
website.com,website.com/index.php, http://website.com, http://www.website.com, website.com/

  • 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

Regards,

DK