0

I am trying to remove index.php from wordpress url by following this video.

It doesn't work. Also I tried several other ways by editing .htaccess file. They all don't work.

In Permalink Settings, if I change the setting to

http://xxxxxxxx/sample-post/

then the "about" page doesn't load, 404. All the ways to edit .htaccess doesn't work. I tried everybody, e.g.: all the methods in this page do not work.

Nicolas S.Xu
  • 13,794
  • 31
  • 84
  • 129
  • Permalink settings should be enough. Can you elaborate more about why about page shows 404 due to permalink changes? – Parth Patel Aug 06 '17 at 19:28
  • Permalinks will show 404 in case mod_rewrite is not loaded, or you are using not apache (nginx for example). Can you show the output of "httpd -M | grep rewrite" ? – Elvis Plesky Aug 07 '17 at 00:30
  • @ElvisPlesky The result is "No command 'httpd' found". The rewrite module is loaded successfully. I can see it in phpinfo.php. – Nicolas S.Xu Aug 07 '17 at 16:00
  • @ParthPatel If I remove the index.php from path by setting Permalink, all the pages will be 404. – Nicolas S.Xu Aug 07 '17 at 16:00

2 Answers2

0

Try this code:

<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>
Chandra Kumar
  • 4,127
  • 1
  • 17
  • 25
0

All my attempts do not work, except this one:

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

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    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>

I got this from this question on stackoverflow by 'Jarrod' at the bottom.

Nicolas S.Xu
  • 13,794
  • 31
  • 84
  • 129