【问题标题】:In joomla instead of Domain Name, IP address shows in address bar(URL rewrite rules)!在joomla而不是域名中,IP地址显示在地址栏中(URL重写规则)!
【发布时间】:2012-03-04 20:06:32
【问题描述】:

在我们学院,我们已经实施了我们的网站并将其托管在我们自己的服务器上。服务器是 Apache,操作系统是 Ubuntu。我的同事向我提出了这个问题。他说必须编辑 httpd.conf 文件以重写域名。 我们的网站是这个-> http://cityengineeringcollege.ac.in 该文件中应该有什么以显示正确的域名。在 joomla 全局配置中,即使我们选择在 SEO 设置中使用 URL 重写,URL 也不会被重写。我们将网页请求从 202.62.95.50 定向到 202.62.95.51。 附言 .htaccess 文件有以下重写部分

RewriteBase /city

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#

配置文件/etc/apache2/httpd.conf有如下代码

<VirtualHost *>
ServerName www.cityengineeringcollege.ac.in
DocumentRoot /var/www
....
</VirtualHost>

我的问题是文档根目录是否正确,就像我认为应该是 /var/www/city 和文件 /etc/hosts 有(作为它的第一行)

127.0.0.1  localhost

我认为应该将服务器名称作为别名

127.0.0.1 localhost cityengineeringcollege.ac.in
cityengineeringcollege.ac.in localhost

这是正确的吗?问题是我渴望把事情做好,我们只能在办公时间(9-5)处理这个问题。我们尝试了各种方法,例如使用 grep 在 /etc/apache2 文件夹中搜索 ServerName 并插入该行

ServerName www.cityengineeringcollege.ac.in

无处不在。那里需要www吗?我们在 sites_available 中有一个名为 city 的文件,它是文件 000-default 的克隆,该文件使用

与 sites_enabled 链接
sudo a2ensite city

【问题讨论】:

    标签: ubuntu joomla web


    【解决方案1】:

    这不是 Joomla 的问题。 Joomla 对所有内容都使用相对 URL,因此域名由 htaccess 文件中的重定向、未正确编码的扩展名或服务器本身控制。如果它在 Drupal 中也这样做,那么我会说这是一个服务器配置问题。

    简单测试 - 将 index.html 上传到您安装了 Joomla 的根目录,然后访问该文件。如果域重定向到 IP 地址,则很可能是服务器配置问题。

    【讨论】:

    • 我浏览了httpd.conf,发现在VirtualHost标签内,ServerName在...之后。是否必须遵循 ServerName 然后 ServerAlias 然后 ServerAdmin 然后 DocumentRoot 然后 的顺序?我的朋友忘了重启服务器,所以我不能说这是否重要。
    【解决方案2】:

    我不确定是什么原因,很可能是您的索引页的一部分。但是当我访问它时,我的浏览器正在被重定向。这意味着在您的 joomla 代码中某处发出以下内容:

    header("Location: http://202.62.95.51/city//");
    

    这导致网站被转发到 IP 地址。如果您没有修改任何代码而只使用了 Joomla,那么它很可能是 joomla 中的一个函数,因为它肯定来自 PHP。

    【讨论】:

    • 他告诉我他使用了drupal并开发了另一个地址为202.62.95.51/dcity/的站点,但问题仍然存在。
    【解决方案3】:

    我的系统管理员说问题已经解决。他没有详细说明所有步骤,但表示 .htaccess 中的 RewriteBase 已改回

    RewriteBase /
    

    并且 DocumentRoot 已更改为 /www/city ,之后它就可以工作了。现在,他正忙于制作我在使用 drupal 开发的一篇评论中提到的 dcity。我忘了提到我们的服务器使用基于名称的虚拟主机。我们与自己的网站一起托管了另一个网站(域名)。我要感谢所有以某种方式提供帮助的回答者。

    【讨论】:

      猜你喜欢
      • 2013-05-21
      • 2017-01-03
      • 2015-09-11
      • 1970-01-01
      • 2020-08-16
      • 2013-02-15
      • 2016-11-11
      • 2019-12-22
      • 1970-01-01
      相关资源
      最近更新 更多