SocialEngine - 重定向.htaccess

时间:2011-10-26 16:00:14

标签: apache .htaccess redirect socialengine

我已在私人服务器上完成了SocialEngine PHP的全新安装。

我现在还需要安装Moodle,并按以下方式访问它:

http://www.example.com/moodle

SocialEngine会创建自己的.htaccess文件,因此每次尝试访问moodle目录时,都会显示“找不到页面。无法找到您尝试访问的页面。”因为重定向强制它在SocialEngine插件中搜索moodle,我希望它重定向到/ httpdocs中的/ moodle /目录。

我非常喜欢.htaccess选项,我需要提示我能做些什么。

.htaccess内容如下:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]

  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]

  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On

# @todo This may not be effective in some cases
FileETag Size

有任何建议或提示吗?

非常感谢你!

问候。

1 个答案:

答案 0 :(得分:1)

我会在每次重写时排除moodle-folder并检查它是否有效。在它工作之后,我会在你并不真正需要它的每个规则中删除它。

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

# Get rid of index.php
RewriteCond %{REQUEST_URI} !^/moodle
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]

# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} !^/moodle
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]

# Try to route missing files
RewriteCond %{REQUEST_URI} !^/moodle
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_URI} !^/moodle
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On

# @todo This may not be effective in some cases
FileETag Size