bit_rainbow2015-04-16 00:06:08
Apache HTTP Server
bit_rainbow, 2015-04-16 00:06:08

Apache mod_rewrite windows server 2008. How?

I want to configure what would be when opening: the
www.myexamplehost.com/google.htmluser saw the content / content www.myexamplehost.com/index.html
There is an almost default apache config.

ServerRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2"
Listen 80

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so

LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule setenvif_module modules/mod_setenvif.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User daemon
Group daemon


ServerAdmin [email protected]
ServerName www.myexamplehost.com:80
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"

<directory />
  Options All
  AllowOverride All
  RewriteEngine on

<VirtualHost *:80>
    ServerName www.myexamplehost.com
   Options Indexes FollowSymLinks MultiViews
    RewriteRule ^/google\.html$ /index.html [L]

DocumentRoot has 2 files: google.html index.html.
At the start of Apache, mod_rewite is loaded.
But when I open: http://www.myexamplehost.com/google.htmlI see the contents of google.html, not index.html.
Redirect is not what I want.
Maybe someone came across? Or is it visible to the naked eye?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Vladimir Golubev, 2015-05-28

the rewrite mod gives this possibility, then it needs to be used in the .htaccess file in the working folder.
For example, I usually have this config:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

but if you need to redirect to an index even if such a file exists, the
RewriteCond %{REQUEST_FILENAME} !-f line
must be removed. True, this will cause problems with connecting styles and scripts ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question