最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - .htaccess file missing from Wordpress install directory

programmeradmin1浏览0评论

This is occuring on my local machine, Lubuntu 18.04 with apache2 and Php 7.2.15.

Steps tried:

  1. Enable hidden files

No .htaccess file seen:

  1. Switch permalink structure to attempt to force Wordpress to create new .htaccess file (if missing). Reload file manager.

No change.

  1. run terminal command whereis .htaccess

Many folders listed but none in the target ( /var/www/html/wptest2/ ). There is nothing even inside /var below:

owner@G700:~$ whereis .htaccess
: /usr/bin/. /usr/sbin/. /lib/x86_64-linux-gnu/. /usr/lib/x86_64-linux-gnu/. 
/usr/lib/. /bin/. /sbin/. /etc/. /etc/.java /lib/. /lib64/. /usr/games/. /usr/local/bin/. 
/usr/local/sbin/. /usr/local/etc/. /usr/local/lib/. /usr/local/games/. /usr/include/. 
/usr/local/. /usr/libexec/. /usr/share/. /opt/emby-server/bin/. 
/opt/dmmediaconverter/bin/. /opt/wine-stable/bin/. /opt/calibre/bin/. 
/home/owner/.nvm/versions/node/v12.4.0/bin/. /home/owner/.local/bin/. 
/snap/bin/. /usr/share/man/man4/. /usr/share/man/fi/. /usr/share/man/pl/. 
/usr/share/man/id/. /usr/share/man/pt_BR/. /usr/share/man/man6/. 
/usr/share/man/ja/. /usr/share/man/hr/. /usr/share/man/sv/. 
/usr/share/man/hu/. /usr/share/man/man1/. /usr/share/man/fr.ISO8859-1/. 
/usr/share/man/zh_CN/. /usr/share/man/man5/. /usr/share/man/zh_TW/. 
/usr/share/man/man8/. /usr/share/man/ca/. /usr/share/man/man3/. 
/usr/share/man/es/. /usr/share/man/nl/. /usr/share/man/da/. 
/usr/share/man/it/. /usr/share/man/uk/. /usr/share/man/ko/. 
/usr/share/man/fr.UTF-8/. /usr/share/man/sl/. /usr/share/man/man2/. 
/usr/share/man/pt/. /usr/share/man/de/. /usr/share/man/de.UTF-8/. 
/usr/share/man/cs/. /usr/share/man/sr/. /usr/share/man/man7/. 
/usr/share/man/fr/. /usr/share/man/pl.UTF-8/. /usr/share/man/vi/. 
/usr/share/man/ru/. /usr/share/man/tr/. /usr/share/info/. /usr/src/bcmwl-
6.30.223.271+bdcom/. /usr/src/linux-headers-4.15.0-58-
generic/.tmp_versions /usr/src/linux-headers-4.15.0-58-generic/.config 
/usr/src/linux-headers-4.15.0-58-generic/. /usr/src/linux-headers-4.15.0-
58/. /usr/src/linux-headers-4.15.0-62-generic/.tmp_versions 
/usr/src/linux-headers-4.15.0-62-generic/.config /usr/src/linux-headers-
4.15.0-62-generic/. /usr/src/linux-headers-4.15.0-62/.

Any ideas what's going on here? The wordpress install fully works. I can access the back end, create posts and pages, navigate across the front end including clicking on links to new pages etc. I have developing a plugin on this side for months. But the .htaccess file seems not to exist.

If someone advises me to simply manually create an .htaccess file my followup question becomes, how can I verify that wordpress uses it? I need this file to enter some rules mandated by a JWT/Rest Api plugin.

Update

I added the following .htaccess file code to a fresh file at /var/www/html/wptest2/

/

iersn // meant to causing a breaking change. But doesn't

# BEGIN WordPress

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

# END WordPress

Wordpress does not break from the line above.

That said my install has always been on ugly links as pretty links cause not-found errors. I believe I don't have that properly setup and I'm sure this .htaccess issue is a contributor.

This is occuring on my local machine, Lubuntu 18.04 with apache2 and Php 7.2.15.

Steps tried:

  1. Enable hidden files

No .htaccess file seen:

https://nimb.ws/4YJfDT

  1. Switch permalink structure to attempt to force Wordpress to create new .htaccess file (if missing). Reload file manager.

No change.

https://nimb.ws/eVkKb3

  1. run terminal command whereis .htaccess

Many folders listed but none in the target ( /var/www/html/wptest2/ ). There is nothing even inside /var below:

owner@G700:~$ whereis .htaccess
: /usr/bin/. /usr/sbin/. /lib/x86_64-linux-gnu/. /usr/lib/x86_64-linux-gnu/. 
/usr/lib/. /bin/. /sbin/. /etc/. /etc/.java /lib/. /lib64/. /usr/games/. /usr/local/bin/. 
/usr/local/sbin/. /usr/local/etc/. /usr/local/lib/. /usr/local/games/. /usr/include/. 
/usr/local/. /usr/libexec/. /usr/share/. /opt/emby-server/bin/. 
/opt/dmmediaconverter/bin/. /opt/wine-stable/bin/. /opt/calibre/bin/. 
/home/owner/.nvm/versions/node/v12.4.0/bin/. /home/owner/.local/bin/. 
/snap/bin/. /usr/share/man/man4/. /usr/share/man/fi/. /usr/share/man/pl/. 
/usr/share/man/id/. /usr/share/man/pt_BR/. /usr/share/man/man6/. 
/usr/share/man/ja/. /usr/share/man/hr/. /usr/share/man/sv/. 
/usr/share/man/hu/. /usr/share/man/man1/. /usr/share/man/fr.ISO8859-1/. 
/usr/share/man/zh_CN/. /usr/share/man/man5/. /usr/share/man/zh_TW/. 
/usr/share/man/man8/. /usr/share/man/ca/. /usr/share/man/man3/. 
/usr/share/man/es/. /usr/share/man/nl/. /usr/share/man/da/. 
/usr/share/man/it/. /usr/share/man/uk/. /usr/share/man/ko/. 
/usr/share/man/fr.UTF-8/. /usr/share/man/sl/. /usr/share/man/man2/. 
/usr/share/man/pt/. /usr/share/man/de/. /usr/share/man/de.UTF-8/. 
/usr/share/man/cs/. /usr/share/man/sr/. /usr/share/man/man7/. 
/usr/share/man/fr/. /usr/share/man/pl.UTF-8/. /usr/share/man/vi/. 
/usr/share/man/ru/. /usr/share/man/tr/. /usr/share/info/. /usr/src/bcmwl-
6.30.223.271+bdcom/. /usr/src/linux-headers-4.15.0-58-
generic/.tmp_versions /usr/src/linux-headers-4.15.0-58-generic/.config 
/usr/src/linux-headers-4.15.0-58-generic/. /usr/src/linux-headers-4.15.0-
58/. /usr/src/linux-headers-4.15.0-62-generic/.tmp_versions 
/usr/src/linux-headers-4.15.0-62-generic/.config /usr/src/linux-headers-
4.15.0-62-generic/. /usr/src/linux-headers-4.15.0-62/.

Any ideas what's going on here? The wordpress install fully works. I can access the back end, create posts and pages, navigate across the front end including clicking on links to new pages etc. I have developing a plugin on this side for months. But the .htaccess file seems not to exist.

If someone advises me to simply manually create an .htaccess file my followup question becomes, how can I verify that wordpress uses it? I need this file to enter some rules mandated by a JWT/Rest Api plugin.

Update

I added the following .htaccess file code to a fresh file at /var/www/html/wptest2/

https://wordpress/support/article/htaccess/

iersn // meant to causing a breaking change. But doesn't

# BEGIN WordPress

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

# END WordPress

Wordpress does not break from the line above.

That said my install has always been on ugly links as pretty links cause not-found errors. I believe I don't have that properly setup and I'm sure this .htaccess issue is a contributor.

Share Improve this question edited Sep 19, 2019 at 16:07 Sean D asked Sep 19, 2019 at 11:40 Sean DSean D 3878 silver badges21 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

whereis is not the right tool to find a file.

whereis - locate the binary, source, and manual page files for a command

You better use find /var/www/html/wptest2/ -name .htaccess to search for your .htaccess.
Try to create a new .htaccess (touch /var/www/html/wptest2/.htaccess) and see if it's possible.

It doesn't appear to be there but in terminal change to your wp root directory and list contents with the -la flag.

cd /var/www/html/wptest2/
ls -la

If needed, create a new .htaccess file from https://wordpress/support/article/htaccess/ or dl WordPress and copy the file over.

Once you know it's in place, you can simply break it to make sure it is being used--add a line 'yes i like tacos' or something.

If your htaccess file is present and not used, it could be your virtual hosts config. Make sure that host has the AllowOverride All directive.

 <VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot "/usr/docs/dummy-host.example"
     ServerName dummy-host.example
     ServerAlias www.dummy-host.example
    <Directory "/usr/docs/dummy-host.example">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
     ErrorLog "/private/var/log/apache2/dummy-host.example-error_log"
     CustomLog "/private/var/log/apache2/dummy-host.example-access_log" common
 </VirtualHost>
发布评论

评论列表(0)

  1. 暂无评论