我正在挖掘网络,并没有找到任何适当的解决方案来解决这个问题。基本上,我想从所有URL中删除子目录( subdirname )名称,例如:
http://test.com/subdirname/
http://test.com/subdirname/content/
http://test.com/subdirname/content/newpage
该网站基于Wordpress,位于 / subdirname 。我有两个.htaccess文件,一个在根目录中:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^(/var|/static)
#RewriteCond %{REQUEST_URI} !^(/index\.php|/var|/static)
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
RewriteCond %{HTTP_HOST} ^(www\.)?test\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !/subdirname/
RewriteRule ^(.*)$ /subdirname/$1 [L]
和/ subdirname /目录中的第二个:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirname/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirname/index.php [L]
</IfModule>
# END WordPress
如果有人有一些提示如何解决,请提供建议。
答案 0 :(得分:4)
您应该可以设置WordPress to display at your root domain but be installed in the subdirectory。只需更改设置 - &gt;下的网站网址即可。一般屏幕。将子目录保留在WordPress URL框中。然后,您将在http://yoursite.com/subdirectory/wp-admin登录,但有人会在http://yoursite.com访问您的网站。