我想http://my_domain.com/forum/index.php/blah_blah_blah
不被重定向到任何地方。重寫規則爲一切,但某些模式
但我想http://my_domain.com/something_else_that_is_not_forum/blah_blah_blah
被重定向到http://my_domain.com/index.php/something_else_that_is_not_forum/blah_blah_blah
因此,基本上,只是沒http://my_domain.com/forum/
前綴一切都應該被重定向。
我有這個.htaccess
:
<IfModule mod_rewrite.c>
# Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase/
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^(?!forum.*)(.*)$ index.php/$2 [L,QSA]
</IfModule>
我認爲,正則表達式應該做的正是我想要的,但在這種情況下,看來我錯了。 http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;df105e678e9b=e1a979a0631bd203b6794debc16ceced
有沒有人知道如何正確地做到這一點?
編輯: 我用這個
<IfModule mod_rewrite.c>
# Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase/
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^\/forum
RewriteRule (?!^forum(?:/.*|)$)^(.*)$ /index.php/$1 [L,NC,QSA]
</IfModule>
,大約說: 如果請求沒有提出任何文件或目錄或符號鏈接,如果它不與啓動它不是/forum
然後 論壇,然後指向/index.php/url。 http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;a5272d5=2fcf142818fc9df2aabb1364942a1d14
也許重寫規則不與分號工作:
這似乎是合乎邏輯訪問此網址時(當然,我們並不需要RewriteCond %{REQUEST_URI} !^\/forum
實際上),但它還是沒有?我不確定。
非常合理。你的規則似乎是合乎邏輯的。但是,訪問此網址:http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;a5272d5=2fcf142818fc9df2aabb1364942a1d14似乎也被重定向到/index.php – goFrendiAsgard
你能請看看我編輯的問題? – goFrendiAsgard
我在本地測試後發佈了這個,我重新測試了這些規則,並且它仍然正常工作,並且沒有轉到'/ index.php'你確定這是你的.htaccess中唯一的代碼,並且沒有其他.htaccess中的其他subdir? – anubhava