admin管理员组文章数量:1289869
I installed WP in subfolder /cms
and it runs live without subfolder. When I use /%postname%/
as permalink I get 404 error on my site. My Server supported mod_rewrite
.
My Code
wp-config.php
define('WP_SITEURL', '');
define('WP_HOME', '');
root
1) .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cms/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cms/index.php [L]
</IfModule>
2) index.php
<?php
define('WP_USE_THEMES', true);
require('./cms/wp-blog-header.php');
?>
/cms
1) .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
2) index.php
<?php
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
?>
Thanks for your help
Ogni
I installed WP in subfolder /cms
and it runs live without subfolder. When I use /%postname%/
as permalink I get 404 error on my site. My Server supported mod_rewrite
.
My Code
wp-config.php
define('WP_SITEURL', 'http://www.sitename.de/cms');
define('WP_HOME', 'http://www.sitename.de');
root
1) .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cms/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cms/index.php [L]
</IfModule>
2) index.php
<?php
define('WP_USE_THEMES', true);
require('./cms/wp-blog-header.php');
?>
/cms
1) .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
2) index.php
<?php
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
?>
Thanks for your help
Ogni
4 Answers
Reset to default 3What I generally do
- Install WP in sub directory.
- Open permalink set required permalink.
- Open settings->general link
- Remove the sub directory name from 'Site Address (URL)'
- Cut the index.php and .htaccess files from sub directory and paste them to root
- change code in index.php as you did.
- Again access settings->permalink save the form
Done. You dont need index.php and .htaccess file in sub directory.
I had similar issue and issue was not in code but was in httpd file
- Open the Apache configuration file located at/etc/httpd/conf/httpd.conf (or apache.conf for ubuntu)
- Change AllowOverride None to AllowOverride All inside the DocumentRoot Directory Directive, normally
my solution to this problem, wich always works in my case;
create a .htaccess file in the subdirectory and add the code wich is generated when you change the permalinks on the bottom of the page.
example of the generated code;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /kimco/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /kimco/index.php [L]
</IfModule>
Get rid of the .htaccess file under /cms and then visit Settings -> Permalinks to flush your rewrite rules. Also make sure the site URL and home URL are set up in the database correctly (like you have in the wp-config).
本文标签: htaccessPermalink Issues by Installing WordPress in SubdirectorySubfolder
版权声明:本文标题:htaccess - Permalink Issues by Installing WordPress in SubdirectorySubfolder 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741468637a2380464.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论