URL使用htaccess的的掩蔽的文件夹名称掩蔽、文件夹、名称、URL

2023-09-02 20:34:46 作者:习惯了一个人面对所有

我试图让我的新版网站上线。我已经建立和测试了301的,从www.example.com/shop到www.example.com/test~~V指导文件。我现在需要能够做的唯一的事情就是让网址只www.example.com显示无/测试。在链接结构方面,我真的不希望这种额外的文件夹在那里。

I am trying to get my new version website online. I have already set up and tested the 301's to direct the files from www.example.com/shop to www.example.com/test. The only thing I now need to be able to do is make the url to show only www.example.com without the /test. In terms of link structure I really don't want this extra folder in there.

我觉得我越来越近,但已经在这几天,只是似乎无法得到它的工作!是否有人可以帮忙吗?

I feel I am getting close, but have been at this for days and just can't seem to get it to work! Can someone please help?

更新!

有没有可能是软件生成SEO友好的URL是造成冲突?难道这是为什么我不能够实现www.example.com,而不是www.example.com/test的网址是什么?

Is it possible that software to generate SEO friendly URLs is causing a conflict? Could this be why I am not able to achieve www.example.com rather than www.example.com/test in the URL?

修改

有与配置文件有冲突,这就是为什么我不能得到code工作。感谢您的帮助。

There was a conflict with the config files, which is why I couldn't get the code to work. Thanks for the assistance.

推荐答案

如果你想运行的应用程序位于子文件夹测试/ 在根目录下,使用下面的rewrite规则并将它们放置在根文件夹的.htaccess

If you want to run application located in a subfolder test/ in the root directory, use following rewrite rules and place them in root folders .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^test/
RewriteRule ^(.*)$ /test/$1 [L,QSA]

然后要求为:

Then requests to:

http://www.example.com/yourscript.php
http://www.example.com/css/style.css
https://m.xsw88.com/allimgs/daicuo/20230902/32.png

将呈现前结果(如果他们在上面的位置,不存在):

Will show results from (if they don't exists in the above location):

http://www.example.com/test/yourscript.php
http://www.example.com/test/css/style.css
https://m.xsw88.com/allimgs/daicuo/20230902/34.png