的.htaccess所有网址中删除子目录名称 [英] .htaccess remove subdirectory name from all URLs

查看:138
本文介绍了的.htaccess所有网址中删除子目录名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挖了网,还没有找到这个问题的任何妥善解决。基本上,我想删除子目录( subdirname )的名字从所有的URL,例如:

I was digging the net and haven't found any proper solution for this issue. Basically, I want to remove subdirectory (subdirname) name from all URLs, e.g.:

http://test.com/subdirname/
http://test.com/subdirname/content/
http://test.com/subdirname/content/newpage

该网站是基于字preSS和位于 / subdirname 。我有两个.htaccess文件,一个在根目录下:

The website is based on Wordpress and located in /subdirname. I've got two .htaccess files, one in root directory:

# 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 /目录:

and second in /subdirname/ directory:

# 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


如果任何人有一些提示怎么解决呢,请指点。


If anyone has some tips how to solve it, please advice.

推荐答案

您应该能够成立的字preSS显示在您的根域,但将其安装在子目录。就在设置 - >通用屏幕下方只更改网站的网址。留在Word中preSS URL中的子目录。然后,你会在登录 http://yoursite.com/subdirectory/wp-admin ,但乡亲访问您的网站在 http://yoursite.com

You should be able to set up WordPress to display at your root domain but be installed in the subdirectory. Just change ONLY the site URL under the Settings-> General screen. Leave the subdirectory in the WordPress URL box. Then you would login at http://yoursite.com/subdirectory/wp-admin, but folks visit your site at http://yoursite.com.

这篇关于的.htaccess所有网址中删除子目录名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆