Set RewriteBase to the current folder path dynamically

后端 未结 3 1768
-上瘾入骨i
-上瘾入骨i 2020-11-28 03:45

Is there any way to set RewriteBase to the path current folder (the folder which the .htaccess file is in) relative to the host root?

I have a CMS and if I move it t

3条回答
  •  被撕碎了的回忆
    2020-11-28 04:37

    The accepted solution did not work for me, I think, but this did: https://web.archive.org/web/20180401034514/http://www.zeilenwechsel.de/it/articles/8/Using-mod_rewrite-in-.htaccess-files-without-knowing-the-RewriteBase.html

    Long story short:

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule ^.*$ %2index.php [QSA,L]
    

提交回复
热议问题