2017-02-27 94 views
0

我使用MAMP創建了一個虛擬主機。當我轉到example.dev時,它運行良好。我只是在example.dev上安裝了一個wordpress,沒有任何問題。當我顯示頁面或帖子時,會在頁面名稱前添加一個/index.php。例如:example.dev/index.php/pagename。 我無法訪問example.dev/pagename,我有一個404錯誤。 在固定鏈接的選項中,它會自動生成/index.php/%year%/%monthnum%/%day%/%postname%/。 我選擇了http://example.dev/example-article/,但它仍然不起作用。index.php在wordpress中使用虛擬主機在url中添加

我有一個htaccess的在根

RewriteEngine On 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

如果有人有一個想法......

謝謝!!

回答

0

到這個URL /index.php/%year%/%monthnum%/%day%/%postname%/將Apache服務器上運行此規則添加到.htaccess文件

RewriteRule ^index.php/(.*)/?$ /$1/ [L] 

高於WordPress的規則:

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

考慮到你的.htaccess有它會基本WordPress的規則看起來像這樣:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index.php/(.*)/?$ /$1/ [L] 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

END WordPress