我具有以下目录结构
Root(www.example.com)/
index.php(simple page with links pointing to subdirectory like www.example.com/subdirectory/index.php?id=1)
subdirectory/
index.php
.htaccess(handling all subdirectory rewriting and working fine)
所以我当前的网址是
www.example.com/subdirectory/10/
所以我想从网址中隐藏“子目录”,所以最终的网址应该看起来像
www.example.com/10/
我尝试通过在我的子目录/.htaccess文件中添加以下规则,但不起作用
RewriteCond %{REQUEST_URI} !(.*)subdirectory
RewriteRule ^(.*)$ subdirectory/$1 [L]
或
RewriteRule ^$ subdirectory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ subdirectory/$1
我的子目录/.htaccess文件
RewriteEngine On
RewriteRule ^([-]?[0-9]+)([-_][^/]*)?/posts/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)?\.html index.php?view=showad&adid=$7&cityid=$1 [QSA]
RewriteRule ^([-]?[0-9]+)([-_][^/]*)?/posts/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)?/page([0-9]*)\.html index.php?view=ads&catid=$3&subcatid=$5&cityid=$1&page=$7 [QSA]
RewriteRule ^([-]?[0-9]+)([-_][^/]*)?/posts/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)? index.php?view=ads&catid=$3&subcatid=$5&cityid=$1 [QSA]
答案 0 :(得分:0)
在您GroupOperation groupOperation = Aggregation.group().count().as("messagesCount").push(Aggregation.ROOT).as("messagesPage");
ProjectionOperation projectOperation = Aggregation.project().andExpression("messagesCount").as("messagesPage")
中,将以下规则插入subdirectory/.htaccess
行的下方:
RewriteEngine
您还将在网站根目录.htaccess中需要这些规则(由于它不存在而创建它):
RewritEngine On
RewriteBase /subdirectory/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /subdirectory/(\S*)\s [NC]
RewriteRule ^ %1? [R=301,L,NE]
# remaining rules go below this