简体   繁体   English

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

[英]How remove part of url from browser with htacess

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我在同一个主机中有 2 个域,在 public_html 文件夹中保留来自域主体的文件夹和 index.php,在 public_html 中有其他名为“domain2.com”的文件夹,其中包含来自www.domain2的 index.php .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实际上,如果输入www.domain1.comwww.domain2.com功能完美,但如果我需要输入www.domain2.com/folder2则无法输入文件夹“folder2”需要以这种方式输入域www.domain2.com /domain2.com/whereber这种方式有效

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我的问题是如何修改 .htacces 文件,以便在输入www.domain2.com/domain2.com/folder2时只显示地址www.domain2.com/folder

This is my code in htaccess这是我在 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我目前使用 php 5.6 的共享主机

Thank you very much and excuse my english非常感谢并原谅我的英语

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/ .基本上现在这意味着您站点的文件位于服务器的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.简而言之,您的域连接到包含另一个名为domain2.com的文件夹的根文件夹,并且看起来domain2.com包含您的站点文件。

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.因此,为了解决此问题,请尝试在您的服务器中找到文件夹domain2.com并将所有文件从domain2.com移动到domain2.com所在的文件夹。

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 ?您使用的是cPanelPlesk之类的共享主机,还是使用iis windows server之类的 vps/dedicated?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM