簡體   English   中英

新Apache上的選項MultiViews的替代方法

[英]Alternative for Options MultiViews on new Apache

我在htaccess中使用

AcceptpathInfo On
Options MultiViews
MultiviewsMatch Handlers

設置漂亮的URL等。 此擴展名在文件名中是可選的。 例如, http: //server.com/index將與http://server.com/index.php相同(更有用的是robots.txt.php,style.css.php等)。 但是,在更新到新版本的XAMPP(Apache 2.4.10和PHP 5.6.3)之后,它不起作用(錯誤403),但是在較舊的XAMPP中,它起作用了。 您是否知道任何其他選擇或如何設置? 錯誤在線

Options MultiViews

實際上,發現可能解決您問題的東西。 因此,對於Apache 2.4,您需要在每個選項前面加上+- ,因此您需要:

Options +Multiviews

如果仍然無法解決問題,也許mod_rewrite可以做到(但是您需要嘗試每個擴展)。 就像是:

RewriteEngine On

# check for PHP extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)$ /$1.php [L]

# chek for HTML extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.*)$ /$1.html [L]

等您要檢查的每個擴展名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM