[英]Writing .htaccess file in Ubuntu
I have a domain http://www.mydomain.com
. 我有一个域名
http://www.mydomain.com
。 My root folder structure is like this. 我的根文件夹结构是这样的。
Root 根
-Wordpress -WordPress
i want to redirect all requests to wordpress folder. 我想将所有请求重定向到wordpress文件夹。 I googled and wrote the file like this
我用谷歌搜索并写了这样的文件
RewriteEngine on
rewritecond %{http_host} http://mydomain.com/ [nc]
rewriterule (.*)$ http://mydomain.com/wordpress [r=301,nc]
I am now getting 404 File not found error. 我现在收到404 File not found错误。 i even tried to use another technique to create an index file and use a
header('location:/wordpress1)
,This works well,but whenever I upload a theme in Wordpress it gives me 500 Internal srver Error.. Anyone who can help me with this Note:I am tagging php because they might use this file 我什至尝试使用另一种技术来创建索引文件并使用
header('location:/wordpress1)
,效果很好,但是每当我在Wordpress中上载主题时,它就会给我500 Internal srver Error ..任何可以帮助我的人注意:我正在标记php,因为他们可能会使用此文件
The HTTP_HOST variable contains the server name that the client issues the HTTP request to. HTTP_HOST变量包含客户端向其发出HTTP请求的服务器名称。 In your case mydomain.com.
在您的情况下为mydomain.com。 The current cond will never match.
当前条件永远不会匹配。 Rewriting the host and redirecting to a subdirectory are different issues.
重写主机并重定向到子目录是不同的问题。
RewriteEngine on
RewriteBase /
# This will redirect mydomain.com URIs to www.mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^.*$ http://www.mydomain.com/$0 [R=301,L]
# This will do an INTERNAL redirect to the wordpress folder
RewriteCond $0 !^wordpress/
RewriteRule ^.*$ wordpress/$0
The cond on the second rule is to prevent an internal redirect loop. 第二条规则的条件是防止内部重定向循环。 $0 is set to "the entire match string".
$ 0设置为“整个匹配字符串”。
Also remove the index file and location. 同时删除索引文件和位置。 It's an invalid syntax and it has all sorts of side-effects for the novice as you have found.
这是一种无效的语法,对新手来说,它具有各种各样的副作用。
Try 尝试
RewriteEngine on
RewriteCond $1 !^(index\.php|wordpress/wp_content)
RewriteRule ^(.*)$ /wordpress/index.php/$1 [L]
The second line are exceptions. 第二行是例外。 You may need to add more to include folders that html needs to include.
您可能需要添加更多内容以包含html需要包含的文件夹。
RewriteCond $ 0!^ wordpress / RewriteRule ^。* $ wordpress / $ 0这是最好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.