Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 如何重定向到域名而不使用尾随符/_Apache_.htaccess - Fatal编程技术网

Apache 如何重定向到域名而不使用尾随符/

Apache 如何重定向到域名而不使用尾随符/,apache,.htaccess,Apache,.htaccess,目前,如果我去我的网站 example.com或example.com/index.php …我被重定向到 example.com/ 但是,在访问主页时,我想停止添加培训 以下是我的htaccess文件。。。 关于如何实现这一点有什么想法吗 提前谢谢 我认为你不能做你想做的事 http://example.com/不是路径的一部分,而是应该被视为一个分隔符,就像URL开头的斜杠一样。如果我在我的浏览器中输入一个URL而不带尾随斜杠,那么在提交该URL的GET请求之前,浏览器实际上会将

目前,如果我去我的网站


example.com或example.com/index.php

…我被重定向到


example.com/

但是,在访问主页时,我想停止添加培训

以下是我的htaccess文件。。。

关于如何实现这一点有什么想法吗


提前谢谢

我认为你不能做你想做的事


http://example.com/
不是路径的一部分,而是应该被视为一个分隔符,就像URL开头的斜杠一样。如果我在我的浏览器中输入一个URL而不带尾随斜杠,那么在提交该URL的GET请求之前,浏览器实际上会将其附加到主机名。没有发生重定向。

只是想知道,
/
有什么问题?如果没有斜杠,
GET/HTTP/1.1\r\nHost:example.com\r\n\r\n
会是什么?
IndexIgnore *

ErrorDocument 400 /error
ErrorDocument 401 /error
ErrorDocument 403 /error
ErrorDocument 404 /error
ErrorDocument 500 /error

RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]

RewriteRule ^(home|cv|handouts|links|contact|copyright|cv)/?$ /index.php?module=home&action=$1
RewriteRule ^(log(in|out))/?$ /index.php?module=authentication&action=$1

RewriteRule ^photos/?$ /index.php?module=gallery&action=album&album=general
RewriteRule ^gallery/?$ /index.php?module=gallery&action=album&album=general
RewriteRule ^gallery/([^/\.]+)/?$ /index.php?module=gallery&action=album&album=$1
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)/?$ /index.php?module=gallery&action=album&album=$1$&page=$2
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?module=gallery&action=item&album=$1$&page=$2&item=$3

RewriteRule ^release/?$ /index.php?module=release&action=release
RewriteRule ^error/?$ /index.php?module=error&action=error