2009-12-21 146 views
0

我打電話給我的網站在本地是這樣的:爲什麼這個RewriteRule會導致內部服務器錯誤?

http://localhost:80/mysite/de/layer1/layer2/module 

在.htaccess我:

RewriteEngine on 

RewriteRule !^((css|js|images)/.*)$ index.php%{REQUEST_URI} [L, NE] 

我試圖重寫爲:

http://localhost:80/mysite/index.php/de/layer1/layer2/module 

任何想法有什麼錯呢?

編輯:如果我只寫這一點,那麼就沒有錯誤:

RewriteRule !^((css|js|images)/.*)$ index.php 

但我想我需要%{REQUEST_URI}事情!

我的配置:Mac OS X的10.6雪豹,MAMP與Apache,MySQL和PHP 5.在細節:

Apache 2.0.63 
MySQL 5.1.37 
PHP 4.4.9 & 5.2.10 
APC 3.0.19 & APC 3.1.2 
eAccelerator 0.9.5.3 
XCache 1.2.2 
phpMyAdmin 2.11.9.5 & phpMyAdmin 3.2.0.1 
Zend Optimizer 3.3.3 
SQLiteManager 1.2.0 
Freetype 2.3.9 
t1lib 5.1.2 
curl 7.19.5 
jpeg 7 
libpng-1.2.38 
gd 2.0.34 
libxml 2.7.3 
libxslt 1.1.24 
gettext 0.17 
libidn 1.15 
iconv 1.13 
mcrypt 2.5.8 
YAZ 3.0.47 & PHP/YAZ 1.0.14 
+2

http://serverfault.com可能更適合 – 2009-12-21 17:24:19

+0

這是真實的;這不是一個編程問題。 – kiamlaluno 2009-12-21 17:28:13

回答

2

我不是很確定你想要什麼,但是這裏有一個重寫規則,它將傳遞給index.php所有不是index.php(以避免無限循環),/js/,/images//css/

RewriteCond %{REQUEST_URI} !^/(index.php|css|images|js)/.*$ 
RewriteRule ^(.*)$ http://%{HTTP_HOST}/index.php/$1 [L] 

對於服務器錯誤也可以是NE標誌誰是供Apache的版本> = 1.3.20

+0

我刪除了^^/(index.php | css | images | js)/.*$中導致無限循環的^。從apache錯誤日誌:「mod_rewrite:達到最大內部重定向數目,假設配置錯誤。」我必須補充說,我的網站被調用到localhost:80/mysite /,所以mysite實際上是根,而不是localhost:80。壞事。我知道。必須爲此設置一個本地主機名。 – openfrog 2009-12-21 18:54:25

1

這是用於通過Drupal的以實現類似任務重寫:

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !=/favicon.ico 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
相關問題