【发布时间】:2017-04-23 07:00:35
【问题描述】:
美好的一天
我最近使用典型的 LAMP 系统在 Linux 上设置了我的新网络服务器。我使用 PhPBB 作为我网站的基础。
一切都在线并可从网络外部访问。
唯一的问题:网址永远不会从 www.gaymerscommunity.com 更改。您可以浏览整个测试论坛、注册部分或网站的任何其他部分,并且它将始终保持相同的 URL,没有 /index /forums /register 或任何其他内容。始终只是基本 URL。
我启用了用 a2enmod 重写,并且我允许覆盖 apache2.conf 中目录上的所有内容;我还在早期更改了 /etc/hosts 文件以包含“127.0.0.1 gaymerscommunity.com”。
其他的几乎都是默认的。
我真的希望论坛上的每个帖子都有一个唯一的 url,或者至少每个论坛都有一个我可以用来将人们引导到适当内容的 url。
我应该从哪里开始?
我的文件夹的根目录中确实有一个 .htaccess 文件,但我从有人说这是他们的 PhPBB 默认的 .htaccess 文件中得到它。所以,我只是把它复制过来并启用了重写。
<IfModule mod_rewrite.c>
RewriteEngine on
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]
#
# If symbolic links are not already being followed,
# uncomment the line below.
# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/
#
#Options +FollowSymLinks
</IfModule>
<IfModule mod_version.c>
<IfVersion < 2.4>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfVersion>
<IfVersion >= 2.4>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfVersion>
</IfModule>
<IfModule !mod_version.c>
<IfModule !mod_authz_core.c>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfModule>
<IfModule mod_authz_core.c>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfModule>
</IfModule>
【问题讨论】:
-
您的网站根目录下的.htaccess 文件是否正确?
-
我确实在根目录中有一个 .htaccess,但我不确定它是否设置正确。我发现另一个用户说这是他的默认设置,我复制了它作为我自己的使用。
-
我在原始帖子中包含了那个 .htaccess 文件。
-
.htaccess 文件的语法可能因 Apache 的版本而异。如果你们的 Apache 版本/发行版相同,请与您的朋友核实。