如何使用htacess从浏览器中删除部分URL

发布于 2025-01-29 05:16:34 字数 1526 浏览 1 评论 0 原文

我在同一托管中有2个域,在文件夹public_html内部保留文件夹和index.php来自域principtal和public_html内部的其他文件夹,其中含有名称为“ domain2.com”的文件夹。 =“ http://www.domain2.com” rel =“ nofollow noreferrer”> www.domain2.com

实际上,如果输入到 www.domain1.com www.domain2.com 如果我功能完美,但是如果我需要输入 www.domain2.com/folder2 不要在文件夹中inter infolder2 域这样的域 www.domain2.com/domain2.com/domain2.com/whereber 和这种方式工作

我的问题是如何修改.htacces文件,以便输入它仅显示地址 www.domain2.com/folder

我在HTACCESS中的代码

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

RewriteCond %{HTTP_HOST} ^(www.)?domain1.com.ar$
RewriteCond %{REQUEST_URI} !^/domain1.com.ar/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain1.com.ar/$1

RewriteCond %{HTTP_HOST} ^(www.)?domain2.com.ar$
RewriteRule ^(/)?$ domain2.com.ar/index.php [L]

</IfModule>

目前使用带有PHP 5.6的共享托管,

非常感谢您,请原谅我的英语

I have 2 domains in the same hosting, inside the folder public_html stay the folders and the index.php from the domain principal and inside the public_html have other folder with the name "domain2.com" where have the index.php from www.domain2.com

Actually if enter to www.domain1.com or www.domain2.com function perfectly but if i need enter in www.domain2.com/folder2 dont work for enter in folder "folder2" need put the domain this way www.domain2.com/domain2.com/whereber and this way works

My question is how do I modify the .htacces file so that when entering www.domain2.com/domain2.com/folder2 it only shows the address www.domain2.com/folder

This is my code in htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

RewriteCond %{HTTP_HOST} ^(www.)?domain1.com.ar$
RewriteCond %{REQUEST_URI} !^/domain1.com.ar/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain1.com.ar/$1

RewriteCond %{HTTP_HOST} ^(www.)?domain2.com.ar$
RewriteRule ^(/)?$ domain2.com.ar/index.php [L]

</IfModule>

I currently use a shared hosting with php 5.6

Thank you very much and excuse my english

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你曾走过我的故事 2025-02-05 05:16:34

您的问题似乎在您网站的根目录配置中。

基本上,现在意味着您的网站文件位于服务器的 root/domain2.com/中。

简而言之,您的域连接到一个根文件夹,该文件夹包含另一个称为 domain2.com 的文件夹,看起来像 domain2.com 包含您的站点文件。

因此,为了解决此问题,请尝试在服务器中找到文件夹 domain2.com ,然后将所有文件从 domain2.com 移动到文件夹中,其中 domain2.com 已找到。

您能指定您正在使用的服务器吗?您是否使用共享托管,例如 cpanel plesk ,或者您使用的是vps/deticic of vps/dettic of iis Windows Server

Your issue seems to be in your site's root directory configuration.

Basically now it means that your site's files are located in server's root/domain2.com/.

In a simple words, your domain is connected to a root folder which contains another folder called domain2.com and looks like domain2.com contains your site files.

So in order to fix this, try to locate folder domain2.com in your server and move all files from domain2.com to folder where domain2.com was located.

Could you please specify what server are you using? Are you using shared hosting like cPanel or Plesk or you are using vps/dedicated like iis windows server?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文