我无法在XAMP 3.2.1 for Windows上使用.htaccess。它适用于我老板的MAMPRO for Mac和我们客户的Apache for Linux。
我收到此错误:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
www.rapsodia.loc
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9
这是完整的文件
RewriteEngine On
RewriteCond %{HTTP_HOST} .*\.ar/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/ar/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.cl/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/cl/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.uy/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/uy/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.br/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/br/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.mx/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/mx/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.co/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/co/$1 [R=301,L]
RewriteCond %{HTTP_HOST} .*\.ve/?$
RewriteRule ^(.*)$ http://www.rapsodia.loc/ve/$1 [R=301,L]
#####Si no es .com. a /ar#####
RewriteCond %{HTTP_HOST} !^rapsodia.loc.$ [NC]
RewriteRule ^$ http://www.rapsodia.loc/ar/$1 [R=301,L]
##############################
RewriteCond %{REQUEST_URI} ^/(uy|ar|cl|ve|mx|co|br)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ /ar/ [OR] %{THE_REQUEST} ^POST\ /ar/
RewriteRule ^ar/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
RewriteCond %{THE_REQUEST} ^GET\ /uy/ [OR] %{THE_REQUEST} ^POST\ /uy/
RewriteRule ^uy/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
RewriteCond %{THE_REQUEST} ^GET\ /cl/ [OR] %{THE_REQUEST} ^POST\ /cl/
RewriteRule ^cl/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
RewriteCond %{THE_REQUEST} ^GET\ /br/ [OR] %{THE_REQUEST} ^POST\ /br/
RewriteRule ^br/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
我可以确认我的Windows主机文件和XAMPP的httpvhosts文件已正确配置,因为我的其他虚拟主机工作正常。
我们做了几次测试,显然这是不起作用的:RewriteRule ^ar/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
。问题源于我们必须重写例如www.rapsodia.local.ar到www.rapsodia.local / ar /以便我们的网站正常工作。显然Apache试图在vhost的路由中找到/ ar /目录,当它找不到它时(因为它只是一个url重写),它会抛出一个错误。
任何帮助都会得到极大的帮助。
答案 0 :(得分:1)
我改变了这些规则
RewriteRule ^ar/(.*)$ %{DOCUMENT_ROOT}/v15/$1 [L]
到
RewriteRule ^ar/(.*)$ /v15/$1 [L]
现在它工作得很好。出于某种原因,%{DOCUMENT_ROOT}
是我问题的根源。
感谢!!!