Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache htaccess仅从url中删除文件夹_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache htaccess仅从url中删除文件夹

Apache htaccess仅从url中删除文件夹,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我试图从我的url中只删除一个特定文件夹。我在这里看到了很多答案,但我找不到适合我的答案。 我有这个网址 我只想删除projects文件夹,以便使用 我在public\u html文件夹中有这个.htacces: RewriteEngine on RewriteCond %{REQUEST_URI} !(.*)projects RewriteRule ^(.*)$ projects/$1 [L] 有了这段代码,我可以访问projcets文件夹,但任何其他地址都会重定向我 例如,显示了/项目

我试图从我的url中只删除一个特定文件夹。我在这里看到了很多答案,但我找不到适合我的答案。 我有这个网址 我只想删除projects文件夹,以便使用

我在public\u html文件夹中有这个.htacces:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)projects 
RewriteRule ^(.*)$ projects/$1 [L]
有了这段代码,我可以访问projcets文件夹,但任何其他地址都会重定向我 例如,显示了/项目的索引 谢谢你

你可以试试这个规则:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f    
RewriteCond %{REQUEST_URI} !^/(projects/|index\.php) [NC]
RewriteRule ^(.+)$ /projects/$1 [L]

这在某种程度上是可行的,但是css和js并没有加载到第一页fR css/js只是在css、js、图像文件中使用绝对路径,而不是相对路径。这意味着您必须确保这些文件的路径以
http://
或斜杠
/
开头。或者,您可以尝试将其添加到页面标题中:
。在具有相同项目文件夹的另一个站点中,我收到以下错误:在此服务器上找不到请求的URL/projects/index.php。此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。几乎。它没有index.php,只有其他php,如test.php。其他站点上可能会出现404,不是吗?