[英]PHP MVC .htaccess Redirect
我想用PHP編寫MVC應用程序,並具有以下文件結構:
/ |-- application | | | ... | |-- public | |-- css | | |-- screen.css | | `-- print.css | |-- scripts | | `-- wlan.sh | |-- bugfixes | | `-- audiofix.sh | `-- index.php `-- .htaccess
這是我的.htaccess文件:
RewriteEngine On
RewriteBase /public
RewriteCond %{REQUEST_URI} !^/public/ [NC]
RewriteRule ^(.*)$ /public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/index.php [L]
什么有效:
什么不起作用:
我已經嘗試了一切。 現在我需要幫助。
解決方案是:
RewriteEngine On
# Stop processing if already in the /public directory
RewriteRule ^public/ - [L]
# Static resources if they exist
RewriteCond %{DOCUMENT_ROOT}/public/$1 -f
RewriteRule (.+) public/$1 [L]
# Route all other requests
RewriteRule (.*) public/index.php [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.