我有这个目录结构

/gallery
/home
    index.php
    (other files here).php
/products
/(other folders here)
index.php

在根index.php有一个简单的重定向:

<?php header('location: /home/');

实际上, home/index.php是网站(我的意思是:HTML,CSS,JS等)的开始位置

现在,由于它是一个动态站点,因此我需要一些重写规则。 在这里,我的评论可以帮助您理解:

# Add a trailing slash to folders that don't have one
# Wehen user types 'mysite.dev/folder' it is converted to 'mysite.dev/folder/'
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]

# Exclude these folders from rewrite process
# Am I right here? Is this rule right?
RewriteRule ^(admin|ajax|assets|blocks|cache|classes|Connections|cron|editor|inc|intranet|lang|loops|pub)($|/) - [L]

# Remember: the root 'index.php' redirects to '/home' folder: then
# we append the Italian language so that Italian site version is shown as default
RewriteRule ^(/home/)?$ /home/index.php?nLang=it [NC,L]

# Start rewriting rules
RewriteRule ^sfogliabile/([\d]+).htm$                   /flip/browser.php?iCat=$1                              [NC,L]
RewriteRule ^depliant/([\d]+).htm$                      /flip/flyer.php?iSpecial=$1                            [NC,L]
RewriteRule ^([a-z]+)/risultati.htm$                    /home/risultati.php?nLang=$1                           [NC,L,QSA]
RewriteRule ^([a-z]+)/cookie.htm$                       /home/cookie.php?nLang=$1                              [NC,L]
RewriteRule ^([a-z]+)/nojs.htm$                         /home/nojs.php?nLang=$1                                [NC,L]
#RewriteRule ^([a-z]+)/professional/$                   /home/pro.php?nLang=$1                                 [NC,L]
RewriteRule ^([a-z]+)/3/([\w-]+)/$                      /products/index.php?nLang=$1&iModule=3                 [NC,L]       # it/3/prodotti/, en/3/products/
RewriteRule ^([a-z]+)/3/([\w-]+)/([\d]+)/([\w-]+).htm$  /products/details.php?nLang=$1&iData=$3&iModule=3      [NC,L]       # it/3/prodotti/1/prodotto-x.htm, en/3/products/1/product-x.htm
RewriteRule ^([a-z]+)/4/([\w-]+)/$                      /foreground/index.php?nLang=$1&iModule=4               [NC,L]       # it/4/primo-piano/, en/4/foreground/
RewriteRule ^([a-z]+)/4/([\w-]+)/([\d]+)/([\w-]+).htm$  /foreground/details.php?nLang=$1&iData=$3&iModule=4    [NC,L]       # it/4/primo-piano/1/articolo-x.htm, en/4/foreground/1/article-x.htm
RewriteRule ^([a-z]+)/5/([\w-]+)/$                      /specials/index.php?nLang=$1&iModule=5                 [NC,L]       # it/5/speciali/, en/5/specials/
RewriteRule ^([a-z]+)/5/([\w-]+)/([\d]+)/([\w-]+).htm$  /specials/details.php?nLang=$1&iData=$3&iModule=5      [NC,L]       # it/5/speciali/1/articolo-x.htm, en/5/specials/1/article-x.htm
RewriteRule ^([a-z]+)/6/([\w-]+)/$                      /gallery/index.php?nLang=$1&iModule=6                  [NC,L]       # it/6/gallerie/, en/6/galleries/
RewriteRule ^([a-z]+)/6/([\w-]+)/([\d]+)/([\w-]+).htm$  /gallery/details.php?nLang=$1&iData=$3&iModule=6       [NC,L]       # it/6/gallerie/1/galleria-x.htm, en/6/galleries/1/gallery-x.htm
RewriteRule ^([a-z]+)/([\w-]+)/([\d]+)/([\w-]+).htm$    /home/page.php?nLang=$1&iData=$3                       [NC,L,QSA]   # it/azienda/1/pagina-x.htm, en/company/1/page-x.htm

# solution from http://stackoverflow.com/a/39931184/160044
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME}     !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME}     !-f
RewriteRule ^([a-z]+)/$             home/index.php?nLang=$1     [L,QSA,NC]

很好,似乎一切都按预期进行,但只有警告。 当我在浏览器中输入mysite.dev + [Enter]时,我被重定向到mysite.dev/home/index.php?nLang=it ,暴露了我不想要的内容并破坏了重写过程:为什么会发生? 我哪里错了?

当我删除/home/index.php?nLang=it部分并按[Enter]时,一切都很好:只有mysite.dev部分,这就是我所期望的(或者至少是mysite.dev/it/也可以)

是否想查看Apache errors.log? 在这里(不知道为什么还要考虑不应将其视为assetspub文件夹),只需将mysite.dev替换为mysite.dev ljpharma.dev

[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '(.*)' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^(admin|ajax|assets|blocks|cache|classes|Connections|cron|editor|inc|intranet|lang|loops|pub|webassist)($|/)' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^(/home/)?$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^sfogliabile/([\\d]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^depliant/([\\d]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.251836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/risultati.htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/cookie.htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/nojs.htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/3/([\\w-]+)/$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/3/([\\w-]+)/([\\d]+)/([\\w-]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/4/([\\w-]+)/$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/4/([\\w-]+)/([\\d]+)/([\\w-]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/5/([\\w-]+)/$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/5/([\\w-]+)/([\\d]+)/([\\w-]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/6/([\\w-]+)/$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/6/([\\w-]+)/([\\d]+)/([\\w-]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/([\\w-]+)/([\\d]+)/([\\w-]+).htm$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^([a-z]+)/$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '^(.*)$' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] strip per-dir prefix: D:/Web/ljpharma/home/index.php -> home/index.php
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace3] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] applying pattern '(^|/)\\.' to uri 'home/index.php'
[Sat Jul 08 16:05:15.252836 2017] [rewrite:trace1] [pid 28420:tid 1232] mod_rewrite.c(477): [client 127.0.0.1:51317] 127.0.0.1 - - [ljpharma.dev/sid#2ee51d8][rid#4ec1ee0/initial] [perdir D:/Web/ljpharma/] pass through D:/Web/ljpharma/home/index.php

有什么帮助吗? 谢谢

编辑:呃...我注意到,如果我在所有其他规则之前放下面的规则(现在还不行),一切似乎都起作用了……这可能是原因吗? 如果是,我是否被迫将其置于其他所有内容之前,或者有解决方法?

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

===============>>#1 票数:0 已采纳

即使我不清楚为什么会根据这些规则更改域,也应该始终在内部重写之前放置重定向。

重写URL时,Apache会反复遍历.htaccess文件,直到URL不再更改为止。 为什么这很重要? 好吧,请看下面的例子:

#The internal rewrite
RewriteRule ^foo$ /bar [L]

#The external redirect
RewriteCond %{HTTPS} =off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

当我们输入URL http://localhost/foo ,Apache将通过规则并匹配第一个规则。 现在它将使用URL http://localhost/bar 再次通过规则,并匹配第二条规则,然后重定向到https://localhost/bar 在遇到R标志之后,并且在当前通过规则的运行停止之后,例如,通过遇到L标志或到达.htaccess文件的末尾,Apache将不会再次评估规则。

如果您将重定向放在首位,则会将http://localhost/foo与redirect-rule匹配,这将使浏览器请求https://localhost/bar 现在,Apache将在新请求中匹配该URL,该URL将不再匹配任何重定向,但将匹配内部重写,并在内部尝试提供资源bar


附带说明:在.htaccess文件中,由于.htaccess文件位于目录中,因此保证匹配的资源不以/开头,并且从匹配的url中删除此目录,并在重写后重新应用。 这样, RewriteRule ^(/home/)?$ ...规则有点傻,因为括号内的部分保证永远不会匹配。 如果您也希望它也匹配以home开头的路径,则将其更改为RewriteRule ^(home/?)?$ ...

  ask by Ivan translate from so

未解决问题?本站智能推荐: