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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.