在joomla而不是Domain Name中,IP地址显示在地址栏中(URL重写规则)!

时间:2012-02-29 05:37:26

标签: ubuntu joomla web

在我们学院,我们已经实施了我们的网站并将其托管在我们自己的服务器上。服务器是Apache,OS是Ubuntu。我的同事向我提出了这个问题。他说必须编辑httpd.conf文件才能重写域名。 我们的网站是This-> http://cityengineeringcollege.ac.in 该文件中应该有什么来显示正确的域名。在joomla全局配置中,即使我们选择在SEO设置中使用URL重写,URL也不会被重写。我们正在将网页请求从202.62.95.50指向202.62.95.51。 P.S .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

3 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

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

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

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

Browser network trace

答案 2 :(得分:0)

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

RewriteBase /

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