Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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重写规则301-处理子文件夹_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache重写规则301-处理子文件夹

Apache重写规则301-处理子文件夹,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我有一个网站,我想确保总是显示为www.mydomain.org,即使用户通过键入mydomain.org进行访问。我知道最好的方法是在.htaccess文件中使用重写规则。我一直在尝试这个,规则是'工作',但不是我想要的。这是我在.htaccess文件中设置的重写规则 Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^teachersplanner.org [NC] RewriteRule ^(.*)$ htt

我有一个网站,我想确保总是显示为www.mydomain.org,即使用户通过键入mydomain.org进行访问。我知道最好的方法是在.htaccess文件中使用重写规则。我一直在尝试这个,规则是'工作',但不是我想要的。这是我在.htaccess文件中设置的重写规则

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^teachersplanner.org [NC]
RewriteRule ^(.*)$ http://www.teachersplanner.org/$1 [R=301,NC]
问题是,我的主机有一个公共的html文件夹,我的代码放在其中,重写规则将其标记到用户提供的URL的末尾

我的意思是:

用户进入www.mydomain.org,一切正常 用户进入mydomain.org,URL转换为www.mydomain.org/public\u html 有人能解释一下如何阻止重写在URL末尾添加公共html吗

RewriteCond %{HTTP_HOST} !^www\.mydomain\.de$
RewriteRule ^(.*)$ http://www.mydomain.de/$1 [R=301,L]

也许这也可以解决您的公共html问题。

使用%{REQUEST\u URI}代替捕获URI:


您的htaccess文件位于何处,是在public_html文件夹中还是在其上方?//可能设置可以解决此问题。htaccess文件位于public_html文件夹上方的文件夹中。将研究重写库-除非你能提供建议-谢谢你的想法,但这给了我同样的问题!
Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^teachersplanner\.org$ [NC]
RewriteRule ^ http://www.teachersplanner.org%{REQUEST_URI}  [R=301,NE]