2017-08-06 112 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问题在底部。