dongzexi5125 2016-01-06 10:44
浏览 82
已采纳

如何在wamp服务器中重定向.htaccess文件

Hey guys im trying to prevent that anybody can access the homepage of my wamp server.

So if somebody types www.example.com then it shows the homepage of the wamp server.

But if somebody tries to enter the www.example.com site then it should be redirected to www.example.com/moodle

This is what i tried so far in the .htaccess file:

 <IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI} !/moodle$ [NC]
 RewriteRule .* /moodle [R=302,L]
</IfModule>

It seems like its creating an infinitive loop.

Here is my whole .htaccess file:

# On some PHP servers it may help if this file is copied
# to the main moodle directory and renamed .htaccess
#
# As soon as you do this, check your web site.  Is it
# still working OK?  If you are getting a "configuration
# error" then you may need to enable overrides by editing
# the main httpd.conf for Apache and in the main server
# or virtual server area, adding something like:
#
# <Directory /web/moodle>
#     AllowOverride All
# </Directory>
#

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^((?!moodle/).*)$ moodle/$1 [NC,L]
</IfModule>

### Firstly, if you are using Apache 2, you need the following
### three lines to allow Apache to pass a PATH_INFO variable
### correctly for URLs like http://server/file.php/arg1/arg2

<IfDefine APACHE2>
    AcceptPathInfo on
</IfDefine>

### Secondly, you can define the default files in the Moodle
### directories as follows:

DirectoryIndex index.php index.html index.htm

### Thirdly, set up some PHP variables that Moodle needs

php_flag file_uploads            1
php_flag short_open_tag          1
php_flag session.auto_start      0
php_flag session.bug_compat_warn 0

### Fourthly, sometimes Apache limits the size of uploaded files
### (this is a separate limit to the one in PHP, see below).
### The setting here turns off this limitation

LimitRequestBody 0


### These are optional - you may not want to override php.ini
### To enable them, remove the leading hash (#)

#php_value upload_max_filesize 2M
#php_value post_max_size 2M
#php_value session.gc_maxlifetime 7200


### You can change the following line to point to the
### error/index.php file in your Moodle distribution.
### It provides a form which emails you (the admin)
### about 404 errors (URL not found).

#ErrorDocument 404 http://example.org/moodle/error/index.php


### People have reported that these can help in some cases
### (unusual) when you see errors about undefined functions

#php_value auto_prepend_file none
#php_value include_path .
  • 写回答

2条回答 默认 最新

  • dongyulian5801 2016-01-06 10:52
    关注

    You can use this rule in site root .htaccess:

    RewriteEngine on
    
    RewriteRule ^((?!moodle/).*)$ moodle/$1 [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料