[英]Internal Redirect - PHP and .htaccess?
Good evening, I wanted to know if it is possible to redirect a request to my page as http://test.diogo.me to the page with the content -> http://www.diogo.me/pages/test/ (this redirection must be internal... the browser should point to http://test.diogo.me ). 晚上好,我想知道是否可以将请求http://test.diogo.me重定向到我的页面到内容-> http://www.diogo.me/pages/test/的页面(此重定向必须是内部的...浏览器应指向http://test.diogo.me )。 I have been reading about .htaccess and I feel that this is the resolution for me.
我一直在阅读有关.htaccess的信息,我认为这是适合我的解决方案。
I have tried with the following code: 我尝试使用以下代码:
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^www\.diogo\.me [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.diogo\.me [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
The output is error 404 file not found :( 输出是未找到错误404文件:(
Am I going in the right track? 我走的路正确吗?
Sorry about my expressing limitations. 对不起,我无法表达自己的意思。 Thanks in advance
提前致谢
Just put this code in your .htaccess and remove your existing lines from there: 只需将这段代码放在您的.htaccess文件中,然后从其中删除现有行:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test\.diogo\.me$ [NC]
RewriteRule ^$ http://www.diogo.me/pages/test/ [L,P]
You were missing the /pages
part 您缺少
/pages
部分
RewriteCond %{HTTP_HOST} !^www\.diogo\.me [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.diogo\.me [NC]
RewriteRule ^(.*)$ /pages/%1/$1 [L]
Assuming the subdomains have the same document-root as the main domain. 假设子域与主域具有相同的文档根目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.