Jump to content

Could some body explain me what this does


Deoctor

Recommended Posts

Hai

i have found this rewrite while searching. Could someone explain me what it does.

 

 

 

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

 

 

Enable URL rewriting
If the domain name contains ".localhost." and
The request does not refer to a directory and
There exists a file named "(request).html" then
(1) Set $1 to the request and (2) continue processing as if the request was actually for "$1.html" instead

Thanks for the reply. I have one more doubt. I guess the

RewriteCond %{HTTP_HOST}
would not be necessary if i am using this on a single site right

coz i have tried this

 

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

 

 

and it is working fine

In practicality, the only way the host name is going to contain "localhost" is if you are running the browser you are testing with, on the same machine that apache is running on.  This is a common thing that people do with WAMP/XAMP/MAMP etc., or sometimes as a security feature, where the assumption is that the server will have a working browser, to facilitate setup/installation. 

 

In summary, that's not a common RewriteCond, and not appropriate for a production server.

Thank you for your reply.yes what you have guessed is correct i am testing it in my local server before implementing it on the production server. but as you can see in my  second post i have eliminated this and could able to achieve what i have opted for.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.