简体   繁体   English

“在此服务器上找不到请求的URL / projectname / pagename /。”WordPress网站上的问题

[英]“The requested URL /projectname/pagename/ was not found on this server.” issue on WordPress website

For my WordPress project, I am getting the error The requested URL /projectname/pagename/ was not found on this server. 对于我的WordPress项目,我收到错误The requested URL /projectname/pagename/ was not found on this server. when I try to set the permalink to Postname: http://10.60.8.118/projectname/sample-post/ . 当我尝试将永久链接设置为Postname: http://10.60.8.118/projectname/sample-post/ The project is hosted on my Ubuntu machine. 该项目托管在我的Ubuntu机器上。

在此输入图像描述

I am able to view the pages or posts with permalinks set as Plain: http://10.60.8.118/projectname/?p=123 我可以查看固定链接设置为Plain: http://10.60.8.118/projectname/?p=123的页面或帖子Plain: http://10.60.8.118/projectname/?p=123

Earlier .htaccess was not writable. 早些时候.htaccess不可写。 So I changed it and now it is writable. 所以我改变了它,现在它是可写的。

content of .htaccess .htaccess的内容

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

The above settings does not work. 以上设置不起作用。 I have also tried changing the base to / (I guess it should be /devcounsyl/ but none of them works.) 我也尝试将基数更改为/(我想它应该是/ devcounsyl /但它们都不起作用。)

content of .htaccess .htaccess的内容

# 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

Also tried: Changing file and folder permissions assuming that that might be causing the issue: 还尝试了:更改文件和文件夹权限,假设可能导致问题:

find . -type d -exec chmod 775 {} \;

find . -type f -exec chmod 664 {} \;

database urls: 数据库网址:

wp_options table has the value http://10.60.8.118/devcounsyl for siteurl and home 对于siteurlhome wp_options表的值为http://10.60.8.118/devcounsyl

Project structure: 项目结构:

/var/www/html/devcounsyl/

The WordPress files are in the project folder and also the .htaccess file is in devcounsyl project folder. WordPress文件位于项目文件夹中,而.htaccess文件位于devcounsyl项目文件夹中。

Turns out that .htaccess was not the issue for me. 事实证明.htaccess对我来说不是问题。 The issue was in server configuration file. 问题出在服务器配置文件中。 Posting my answer in case any one bumps into similar issue and looking for a solution. 发布我的答案,以防任何人遇到类似问题并寻找解决方案。

For AWS EC2 server: 对于AWS EC2服务器:

Step 1: Edit configuration file 第1步:编辑配置文件

sudo nano /etc/httpd/conf/httpd.conf

Edit this file and change 编辑此文件并进行更改

<Directory /var/www/html/wordpress/>
    AllowOverride None
 </Directory>

to

<Directory /var/www/html/wordpress/>
    AllowOverride All
 </Directory>

Note that here, /var/www/html/wordpress/ is path to the root folder where WordPress project was hosted. 请注意, /var/www/html/wordpress/是托管WordPress项目的根文件夹的路径。

Step 2: Restart server 第2步:重启服务器

Please don't forget to restart your server after you do the changes to the .conf file. 在对.conf文件进行更改后,请不要忘记重新启动服务器。

sudo service httpd restart

For Ubuntu server: 对于Ubuntu服务器:

Step 1: Edit configuration file 第1步:编辑配置文件

sudo gedit /etc/apache2/apache2.conf

Edit this file and change 编辑此文件并进行更改

<Directory /var/www/html/wordpress/>
    AllowOverride None
 </Directory>

to

<Directory /var/www/html/wordpress/>
    AllowOverride All
 </Directory>

Note that here, /var/www/html/wordpress/ is path to the root folder where WordPress project was hosted. 请注意, /var/www/html/wordpress/是托管WordPress项目的根文件夹的路径。

Step 2: Restart server 第2步:重启服务器

Please don't forget to restart your server after you do the changes to the .conf file. 在对.conf文件进行更改后,请不要忘记重新启动服务器。

sudo service apache2 restart

If WordPress is installed in a subdirectory then you should move your .htaccess into that subdirectory (if not already) and remove the slash prefix from the RewriteRule substitution , otherwise the RewriteBase directive will have no effect. 如果WordPress安装在子目录中,那么你应该将.htaccess移动到该子目录(如果还没有)并从RewriteRule 替换中删除斜杠前缀,否则RewriteBase指令将不起作用。 For example: 例如:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase is not required if .htaccess file is in the /devcounsyl dir
#RewriteBase /devcounsyl/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress

Although, if the .htaccess file is already in the /devconsyl subdirectory, then the RewriteBase directive is not actually required (providing you remove the slash prefix from the RewriteRule substitution , as mentioned above). 虽然,如果.htaccess文件已经在/devconsyl子目录中,那么实际上并不需要RewriteBase指令( RewriteBase您从RewriteRule 替换中删除了斜杠前缀,如上所述)。

The .htaccess file would need to be in the WordPress subdirectory for the first RewriteRule to match. .htaccess文件需要在WordPress子目录中才能匹配第一个RewriteRule (ie. RewriteRule ^index\\.php$ - [L] ) (即RewriteRule ^index\\.php$ - [L]

By removing the slash prefix, you are making the substitution relative to the directory containing the .htaccess file. 通过删除斜杠前缀,您将相对于包含.htaccess文件的目录进行替换 The RewriteBase only applies to relative substitutions and simply overrides the default (relative) path. RewriteBase仅适用于相对替换,并简单地覆盖默认(相对)路径。


If, however, the .htaccess file is located in the document root of your domain (ie. not the WordPress root) then you would need to modify your .htaccess like this: 但是,如果.htaccess文件位于域的文档根目录中(即不是WordPress根目录),那么您需要修改.htaccess如下所示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase is required if .htaccess file is in document root
RewriteBase /devcounsyl/
RewriteRule ^devcounsyl/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在此服务器上找不到请求的 URL /ProjectName/users。 Laravel - The requested URL /ProjectName/users was not found on this server. Laravel 在此服务器上找不到请求的 URL。 - php,wordpress - The requested URL was not found on this server. - php, wordpress 在此服务器上找不到请求的URL。 Magento与oAuth - The requested URL was not found on this server. Magento with oAuth Apache:在此服务器上找不到请求的 URL /。 阿帕奇 - Apache: The requested URL / was not found on this server. Apache 在此服务器上找不到请求的URL。 在PHP codeigniter上 - The requested URL was not found on this server. on php codeigniter 在此服务器上找不到请求的URL。 阿帕奇 - The requested URL was not found on this server. Apache 未找到 Object。 在此服务器上未找到请求的 URL。 本地主机 Laravel Xampp 问题 - Object not found! The requested URL was not found on this server. localhost Laravel Xampp Issue 未找到 在此服务器上未找到请求的 URL。 xampp 错误 - Not Found The requested URL was not found on this server. xampp error 找不到在此服务器上找不到请求的URL / emr / login。 在Laravel - Not Found The requested URL /emr/login was not found on this server. in Laravel 未找到对象! 在此服务器上找不到请求的 URL。 本地主机 - Object not found! The requested URL was not found on this server. localhost
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM