简体   繁体   English

"使用 htaccess 从 URL 中删除文件夹名称"

[英]Remove folder names from the URL using htaccess

I am stuck in here with htaccess.我被htaccess困在这里。 I've searched and tried many tutorials and problem solutions but couldn't achieve what I want.我搜索并尝试了许多教程和问题解决方案,但无法实现我想要的。

I want to remove folder names from the website link.我想从网站链接中删除文件夹名称。 My htaccess file is in the root directory ie "testing"我的 htaccess 文件位于根目录中,即“testing”

What my link looks like:我的链接是什么样的:

http://localhost/testing/sub/test.php

What I want:我想要的是:

http://localhost/test.php

Following is my htaccess以下是我的 htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /(.*) /testing/sub/$1    [L]

Use this line in your root .htaccess在你的根 .htaccess 中使用这一行

RewriteRule ^test.php$ \/testing\/sub\/test.php<\/strong>重写规则 ^test.php$ \/testing\/sub\/test.php<\/strong>

"

The best way to do that is to go to the folder that contains all the files for your site .最好的方法是转到包含您站点的所有文件的文件夹。 For example if the folder is named " site1 " go to it form your cpanel copy all the files to your Public_html folder例如,如果文件夹名为“site1”,请从您的 cpanel 中将所有文件复制到您的 Public_html 文件夹

one way to do that is once you locate the folder that has your site files and you are looking at them , click on select all to select all the files or if you do not see select all click on the first file in the folder it should be highlighted then scroll down to the very last file of the folder press the shift button on your keyboard and click the last file now everything should be highlighted.一种方法是,一旦您找到包含站点文件的文件夹并且正在查看它们,单击全选以选择所有文件,或者如果您没有看到全选,请单击文件夹中的第一个文件。突出显示然后向下滚动到文件夹的最后一个文件按键盘上的 shift 按钮并单击最后一个文件现在应该突出显示所有内容。 if not repeat the process again until everything is highlighted .如果不重复该过程,直到所有内容都突出显示。

right click and click on copy右键单击并单击复制

on the little popup window on the bottom you should see copy file to make sure the folder you're copying the files to is /public_html then click on the copy files button on the lower right corner of the popup window .在底部的小弹出窗口中,您应该看到复制文件,以确保您要将文件复制到的文件夹是 /public_html,然后单击弹出窗口右下角的复制文件按钮。

all of your files should now be in the pulic_html folder you need to now change your configuration.php file right click on and click on edit once the popup window opens click on edit again it should open in your browser look for the code line that says :您的所有文件现在应该在 pulic_html 文件夹中您现在需要更改您的 configuration.php 文件右键单击并单击编辑一旦弹出窗口打开再次单击编辑它应该在您的浏览器中打开查找代码行说:

public $live_site = ' http://vivendishop.com '; public $live_site = ' http://vivendishop.com ';

if your domain name has a /folder remove it and save如果您的域名有 / 文件夹,请将其删除并保存

that should do it hope that works for you应该这样做希望对你有用

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

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