从URL跳过Joomla [英] Skip Joomla from the URL

查看:135
本文介绍了从URL跳过Joomla的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站在Joomla上运行,Joomla安装在 http://example.com/joomla 中,但是我的网址仍然是 http://example.com (我从根目录访问Joomla文件夹).我发现将joomla与网站上的其他文件和文件夹分开是很好的,但是与访问者在URL中看到joomla无关,因为最好只看到URL中与他们在我的搜索内容上有更多关系的内容地点. 所以我想让我们从URL中跳过joomla.而且由于Cloudflare,所有URL必须都是www-URL才能正常工作.

My site runs on Joomla, which is installed in http://example.com/joomla, but my URL is still http://example.com (I access the Joomla folder from the root). I find it good to have joomla separated from other files and folders on my site, but irrelevant that visitors see joomla in the URL, since it's better they see only things in the URL that has more to do with what they are searching for on my site. So I thought let's skip joomla from the URL. And because of Cloudflare all URLs must be www-URLs in order to work properly.

由于以下解决方案,我得以实现:

I was able to achieve this thanks to the below solution:

https://stackoverflow.com/a/35047905/5681573

我的修改版本:

.htaccess:

.htaccess in the root:

RewriteEngine on
RewriteCond %{THE_REQUEST} !joomla/
RewriteRule ^(.*)$ /joomla/$1 [L]

joomla/子目录中的

.htaccess:

.htaccess in the joomla/ subdirectory:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

在我的解决方案中,包括从非www URL到www-URL的重定向以及从http到https的重定向.

In my solution is included redirection from non-www URLS to www-URLs and from http to https.

在joomla/configuration.php中,我设置了$ live_site =" https://example.com ",然后 将tmp和日志文件夹更改为:

In joomla/configuration.php I set $live_site = "https://example.com" and changed the tmp and log-folders to:

  • myserverpath/public_html/joomla/administrator/logs
  • myserverpath/public_html/joomla/tmp

一切都很好.现在,当我对其进行测试时,结果如下:

Everything looks fine. Now when I test it these are the results:

  • https://www.example.com correctly loads content from https://www.example.com/joomla without showing /joomla in the URL
  • non-www URLS redirect to www-URLs
  • http redirects to https

但是非www网址存在问题:

But there is a problem with non-www URLs:

  • https://example.com redirects to https://www.example.com/joomla
  • http://example.com redirects to https://www.example.com/joomla

将非www URL重定向到www-URL时,不会从URL中跳过Joomla. 网址中以www开头的所有其他链接均正确显示,但未包含"joomla".无论您直接输入地址还是通过网站上的链接或按钮到达该地址:joomla始终都会从任何www-URL中跳过.只是那一刻,非www URL被重定向到无法正常工作的www-URL,并且URL中出现了单词"joomla".

Joomla is not skipped from the URL when non-www URLs are redirected to www-URLs. All other links that begin with www are correctly showing without 'joomla' in the URL. No matter if you type the address directly or if you arrive there via a link or button on the website: joomla is further always skipped from any www-URL. It's just that moment that a non-www URL is redirected to a www-URL that it's not working and the word 'joomla' is appearing in the URL.

还有一个例外是管理URL,这也是一个问题,非常独特,因为在使用www-URL和非www-URL时都无法从URL跳过Joomla:

And also 1 exception is the admin URL, which also is a problem, unique because it's failing to skip Joomla from the URL both when used the www-URL as well as the non-www-URL:

  • https://example.com/administrator redirects to https://www.example.com/joomla/administrator
  • https://www.example.com/administrator redirects to https://www.example.com/joomla/administrator

我搜索了无数小时的结果.

I searched hours and hours without result.

我尝试解决以下问题:

  • 将$ live_site更改为"(无济于事)
  • 将$ live_site更改为" https://www.example.com "(无济于事)
  • 将$ live_site更改为" https://example.com "(无济于事)
  • 将joomla/.htaccess中的RewriteBase更改为RewriteBase/(一点都不更改)
  • 将joomla/.htaccess中的RewriteBase更改为RewriteBase/joomla/(一点都不更改)
  • changing $live_site to '' (not helping)
  • changing $live_site to 'https://www.example.com' (not helping)
  • changing $live_site to 'https://example.com' (not helping)
  • changing RewriteBase in joomla/.htaccess to RewriteBase / (no change at all)
  • changing RewriteBase in joomla/.htaccess to RewriteBase /joomla/ (no change at all)

非常欢迎一些有用的提示或可能的解决方案.预先感谢.

Some useful hints or possible solutions are very welcome. Thanks in advance.

关于我在此页面上发布的解决方案答案中的前三行代码:我仅为管理员URL创建了它们:

About the first three lines of codes in the solution answer that I posted on this page: I created them only for the admin URL:

    RewriteCond %{REQUEST_URI} (.*)administrator$
    RewriteCond %{REQUEST_URI} !/$
    RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]

尽管joomla已成功从所有URL中跳过(请参阅解决方案的答案),但对我来说,问题仍然是,为什么需要如上所示添加尾部斜杠才能解决admin URL.否则,当您不添加这三行代码时,管理URL将重定向到joomla/administrator,并将在URL中显示joomla. 这与定义设置有关系吗?...谁知道...

Although joomla is skipped from all URLs successfully (see answer with solution), for me the question remains why it's needed to add the trailing slash as you see above, in order to solve it for the admin URL. Otherwise, when you don't add these three lines of codes the admin URL will redirect to joomla/administrator and will show joomla in the URL. Does this have anything to do with the defines settings?... Who knows...

推荐答案

我很高兴地说找到了解决我问题的方法.

I'm glad to say the solution for my issue is found.

对于有相同问题的任何人,以下是解决方法:

For anyone who has the same problem, here is the solution:

  • 不需要在joomla/目录的htaccess中有任何重写器,只是不要在该htaccess文件中编写重写器
  • htaccess根文件中的
  • 负责添加重写器的位置:您应将它们放在htaccess文件的TOP上.这些代码可以解决问题:

  • no need to have any rewriterule in the htaccess of the joomla/ directory, just don't write rewriterules in that htaccess file
  • in the root htaccess file take care of where you add the rewriterules: you should put them on TOP of the htaccess file. These codes will do the trick:

# keep codes on top !!!
RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)administrator$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} joomla/
RewriteRule ^joomla/(.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !joomla/
RewriteRule ^(.*)$ /joomla/$1 [L]

感谢并感谢伟大的SiteGround支持团队(我的提供商),因为他们能够找到使一切正常运行的解决方案.

Thanks and credits to the great SiteGround support team (my provider), as they were able to find the solution to make everything work as expected.

这篇关于从URL跳过Joomla的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆