0
我使用apache建立了一個私人服務器(樹莓)。 爲網站配置文件:Apache:差異virtualhost和htaccess
<VirtualHost *:80>
ServerName me.example.com
ServerAlias me.example.com
RewriteEngine On
#only rewrite if not one of the followed files is requested
RewriteCond %{REQUEST_URI} !^/images/.*\.(jpg|ico|png|mp4|ogg)
RewriteCond %{REQUEST_URI} !^/css/.*\.css
RewriteCond %{REQUEST_URI} !^/js/.*\.js
#rewrite all requests to index.php and get path (only intern)
RewriteRule ^/([^/]*)/(.*)$ /index.php?lang=$1&path=$2 [NC]
DocumentRoot /var/www/my/root
<Directory /var/www/my/root>
Options FollowSymLinks
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
1)如果我現在申請一個「子頁面」像/impressum.php。它會告訴我impressum,而不是重寫到索引文件。爲什麼?
2.)現在我將重寫引擎的一部分複製到.htaccess文件中,並且它不再工作。這兩個文件的區別在哪裏?我需要改變什麼,所以它會起作用? 我的.htaccess文件看起來像:
Options +FollowSymLinks
RewriteEngine On
#only rewrite if not one of the followed files is requested
RewriteCond %{REQUEST_URI} !^/images/.*\.(jpg|ico|png|mp4|ogg)
RewriteCond %{REQUEST_URI} !^/css/.*\.css
RewriteCond %{REQUEST_URI} !^/js/.*\.js
#rewrite all requests to index.php and get path (only intern)
RewriteRule ^/([^/]*)/(.*)$ /index.php?lang=$1&path=$2 [NC,L,QSA]
在此先感謝
這條線:(。*) 重寫規則^ /([^ /] *)/ $ /index.php?lang=$1&path=$2 [NC,L,QSA] 需求被編輯爲: RewriteRule ^([^ /] *)/(。*)$ /index.php?lang=$1&path=$2 [NC,L,QSA] (第一個斜線不在)。現在這個概念再次運作。最後一個問題: 只是主要的工作:所以如果我打電話給me.example.com/de/test它的作品。如果我嘗試訪問:me.example.com/de/test/subtheme。它將我重定向到主頁而不是existend子頁面! – user5408952