1

我正在挖掘网络,并没有找到任何合适的解决方案来解决这个问题。基本上,我想从所有 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

如果有人有一些提示如何解决它,请指教。

4

1 回答 1

4

您应该能够将WordPress 设置为在您的根域中显示,但安装在子目录中。只需在“设置”->“常规”屏幕下更改站点 URL。将子目录保留在 WordPress URL 框中。然后您将在http://yoursite.com/subdirectory/wp-admin登录,但人们会在http://yoursite.com访问您的网站。

于 2012-07-15T01:52:14.560 回答