English 中文(简体)
htaccess www 到非 www 不为子目录工作
原标题:htaccess www to non www does not work for sub directories
  • 时间:2012-05-25 14:14:34
  •  标签:
  • .htaccess

我使用以下的密码。

. 根文件夹中的 ht 访问权限

#for redirecting www to non-www
RewriteCond %{HTTP_HOST} ^www.(.*)
RewriteRule (.*) http://%1/$1 [R=301,L]

#temporary redirect root to dir/
RedirectMatch ^/$ /dir/

. 在目录文件夹中的 ht 访问权限

RewriteEngine  on
#for changing index file to a custom one
DirectoryIndex abc.php?tag=ho

#for simple url
RewriteRule ^what/([^/]*).html$ /dir/abc.php?tag=$1 [L]

现有代码www.domain.com 改用域名.com,但www.domain.com/dir/没有改用。

我需要修正两件事:

  1. Redirect www to non wwww
  2. Redirect domain.com to domain.com/dir/

请指引我

问题回答

正在合并 Redirect( 匹配) 和 rebrecule 需要麻烦。 而不是使用您的 RedectMatch :

RewriteCond $1 !^dir/
RewriteRule ^(.*)$ /dir/$1 [R=301,L]




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签