2017-08-06 80 views
0

我想通過以下this video從wordpress網址中刪除index.php。從wordpress URL刪除index.php

它不起作用。另外我通過編輯.htaccess文件嘗試了其他幾種方法。他們都不工作。

在永久設置,如果我將設置更改爲

http://xxxxxxxx/sample-post/

則「關於」頁面沒有加載,404的所有方式來編輯的.htaccess不起作用。我嘗試過所有人,例如:this page中的所有方法都不起作用。

+0

永久設置應該足夠了。您能詳細說明由於固定鏈接更改導致頁面顯示404的原因嗎? –

+0

如果mod_rewrite未加載,或者您使用的不是apache(例如nginx),則固定鏈接將顯示404。你能顯示「httpd -M | grep rewrite」的輸出嗎? –

+0

@ElvisPlesky結果是「No command'httpd'found」。重寫模塊已成功加載。我可以在phpinfo.php中看到它。 –

回答

0

試試這個代碼:

<IfModule mod_rewrite.c> 
Options +FollowSymlinks 
# Options +SymLinksIfOwnerMatch 
RewriteEngine On 

# On some hosts (including Rackspace), you need to remove the "#" that comes before RewriteBase to avoid 404 errors: 
# RewriteBase/

# Block access to hidden files and directories. 
RewriteCond %{SCRIPT_FILENAME} -d [OR] 
RewriteCond %{SCRIPT_FILENAME} -f 
RewriteRule "(^|/)\." - [F] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpe?g|gif)$ $1.$3 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php [L] 
</IfModule> 
+0

它不起作用。我在AWS上使用Ubuntu 16和apache2。感謝分享代碼。 –

0

我所有的努力沒有工作,除了這一個:

http://www.jarrodoberto.com/articles/2011/11/enabling-mod-rewrite-on-ubuntu

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www 
    <Directory /> 
     Options FollowSymLinks 
     AllowOverride All         <- HERE 
    </Directory> 
    <Directory /var/www/> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All         <- HERE 
     Order allow,deny 
     allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
     AllowOverride None 
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
     Order allow,deny 
     Allow from all 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 

    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    Alias /doc/ "/usr/share/doc/" 
    <Directory "/usr/share/doc/"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride None 
     Order deny,allow 
     Deny from all 
     Allow from 127.0.0.0/255.0.0.0 ::1/128 
    </Directory> 

</VirtualHost> 

我通過 '賈羅德' 得到這個從計算器this問題在底部。