我想要一個簡單的.htaccess重寫規則工作,但我似乎無法工作。不能得到.htaccess mod_rewrite規則工作 - 404沒有找到
我的.htaccess的樣子:
RewriteEngine On
RewriteRule ^api$ phpinfo.php
ErrorDocument 404 /error.php
php_flag display_errors on
php_flag display_startup_errors on
php_flag file_uploads on
php_value error_reporting 2047
php_value max_input_time 60
php_value post_max_size 8M
php_value upload_max_filesize 2M
當我訪問/api
,我得到一個404錯誤,指出/api
無法找到。
我的Apache的conf文件看起來像:
<IfModule mod_ssl.c>
NameVirtualHost 10.104.17.3:443
<VirtualHost 10.104.17.3:443>
ServerName orddev.foo.com.au
DocumentRoot /var/www/orddev.foo.com.au___443/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "/var/www/orddev.foo.com.au___443/html">
Options FollowSymLinks MultiViews IncludesNOEXEC
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_php5.c>
php_admin_value upload_tmp_dir "/var/www/orders.foo.com.au___443/resources/_tmp/upload/"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
</IfModule>
ErrorLog logs/orddev.foo.com.au___443/ssl_error.log
CustomLog logs/orddev.foo.com.au___443/ssl_access.log combinedio
CustomLog logs/orddev.foo.com.au___443/ssl_request.log ssl
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:!SSLv2
SSLCertificateFile /etc/pki/tls/certs/orddev.foo.com.au.crt
SSLCertificateKeyFile /etc/pki/tls/private/orddev.foo.com.au.key
<Files ~ "\.(cgi|shtml|phtml|php|php3?)$">
SSLOptions +StdEnvVars
</Files>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
任何想法,我做錯了嗎? 我知道正在讀取.htaccess,就好像我更改了404文檔一樣,我得到的關於404文檔沒有正確設置的錯誤。
這不是評論:(。的LoadModule rewrite_module模塊/ mod_rewrite.so。我已經驗證該文件是否存在。'phpinfo()'顯示加載模塊下的'mod_rewrite'。 – Lock 2013-05-09 01:32:42
嗯,我只是把規則設置爲'RewriteRule^phpinfo.php $ index.php '並且它加載了'index.php',但是如果我將它改爲RewriteRule'^ api $ index.php'並訪問'https:// foo.bar.com.au/api',則不行。 – Lock 2013-05-09 01:43:40
很奇怪。試試'RewriteRule^api.php $ index.php'? – 2013-05-09 01:46:12