如果URL包含單詞「博客」,那麼下面的塊應在.htaccess的.htaccess如果URL中包含「博客」,然後執行規則
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
執行我試着在加入RewriteCond %{REQUEST_URI} ^/blog
頂部,但失敗。
PS:
我加
RewriteCond %{ENV:REDIRECT_rewritten} !=1
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$ [NC]
RewriteRule ^([^/]*)$ /%1/$1? [R=301,L]
RewriteCond %{REQUEST_URI} !^/(js)/
RewriteRule ^([a-z]{2})(?:/([^/]+))?$ $2?lang=$1 [NC,L,QSA,E=rewritten:1]
這使得它如此比如當你去example.com/fr
它就像example.com/index.php?lang=fr
(除非它example.com/js...
寫在規則)
將你的最後一個移動到'/ blog/.htaccess'中(如果它不存在,就創建它) – anubhava