合并两个htaccess文件

时间:2014-02-03 13:42:35

标签: .htaccess mod-rewrite

我遇到了问题并且自己找不到答案,所以也许有人可以帮助我。

我有这个网址: www.horden-des-chaos.de 它有自己的.htaccess文件

# These folders will not be touched.
RewriteEngine On
RewriteCond %{REQUEST_URI} "/css/" [OR]
RewriteCond %{REQUEST_URI} "/js/" [OR]
RewriteCond %{REQUEST_URI} "/img/"
RewriteRule (.*) $1 [L]

# Then have your redirect rule
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/_]+)$ /index.php?url=$1 [NC,L]

现在有一个名为“/ forum /”的目录(http://www.horden-des-chaos.de/forum/) 有一个带有“prettyurl”插件的forumsoftware(SimpleMachinesForum)的完整安装,它创建了这个.htaccess

# PRETTYURLS MOD BEGINS
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: February 3, 2014, 12:18

RewriteEngine on
RewriteBase /

# Rules for: actions
RewriteRule ^(activate|admin|announce|attachapprove|buddy|calendar|clock|collapse)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(coppa|credits|deletemsg|display|dlattach|editpoll|editpoll2|emailuser)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(findmember|groups|help|helpadmin|im|jseditor|jsmodify|jsoption)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(lock|lockvoting|login|login2|logout|markasread|mergetopics|mlist)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(moderate|modifycat|modifykarma|movetopic|movetopic2|notify|notifyboard|openidreturn)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(pm|post|post2|printpage|profile|quotefast|quickmod|quickmod2)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(recent|register|register2|reminder|removepoll|removetopic2|reporttm|requestmembers)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(restoretopic|search|search2|sendtopic|shoutbox|smstats|suggest|spellcheck)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(splittopics|stats|sticky|theme|trackip|about:mozilla|about:unknown|unread)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(unreadreplies|verificationcode|viewprofile|vote|viewquery|viewsmfile|who|\.xml)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(xmlhttp)/?$ ./index.php?pretty;action=$1 [L,QSA]

# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# PRETTYURLS MOD ENDS

我可以得到www.horden-des-chaos / forum /可以调用并显示论坛的索引,但是如果我打电话给www.horden-des-chaos / forum / offentliche-news /我被重定向到www.horden-des-chaos.de索引而不是被叫论坛。

任何想法如何解决? 它与论坛子域(forum.horden-des-chaos.de)一起工作,但是对于两者都使用相同的URL。

PS:我不是母语为英语的人,我尽我所能:/

1 个答案:

答案 0 :(得分:0)

您可以从原始重写中排除论坛子目录:

# These folders will not be touched.
RewriteEngine On
RewriteCond %{REQUEST_URI} "/css/" [OR]
RewriteCond %{REQUEST_URI} "/js/" [OR]
RewriteCond %{REQUEST_URI} "/img/"
RewriteRule (.*) $1 [L]

# Then have your redirect rule
# RewriteEngine On
RewriteCond %{REQUEST_URI} !/forum [NC]
RewriteRule ^([a-zA-Z0-9-/_]+)$ /index.php?url=$1 [NC,L]

此致