Mod_rewrite 显示来自通配符域的重定向
我正要把 mod_rewrite 踢到路边。谈论“与他人相处不好”。有没有相关的巫医可以帮我解决这个问题?
我设置了通配符 dns 来识别用户。我想从:
http://username.domain.com/foo/bar
至:
https://www.domain.com/qux/waldo/username/ foo/bar
这可能吗?
我正在使用 codeigniter 进行开发,它已经在 .htaccess 中拥有自己的 mod_rewrite 指令,以删除 index.php。
这是我所得到的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.idseal\.local.*$
RewriteRule (.*) /site/assign/$1
#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I am so about to kick mod_rewrite to the curb. Talk about "doesn't play well with others." Are there any witchdoctors about that can help me with this?
I have wildcard dns set up to identify users. I would like to go from:
http://username.domain.com/foo/bar
to:
https://www.domain.com/qux/waldo/username/foo/bar
Is this possible?
I'm developing with codeigniter and it has it's own mod_rewrite directives in .htaccess already, to strip out the index.php.
Here's what I've got:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.idseal\.local.*$
RewriteRule (.*) /site/assign/$1
#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一行验证我们是否在主域上,第二行将匹配是否有 www,如果有 www,它将保留在 %1 上,因此如果有 inst,则不进行任何更改,数据将被写入%2 并且会重写得很好。
我不能 100% 确定这会满足您的需求,但请尝试一下并报告回来,我会尽力帮助您。
First line verify if we are on the main domain or not, second line will match if there is a www or not, if there is a www it will be held on %1 thus making no changes if there inst, the data will be into %2 and will rewrite just fine.
I am not 100% sure this will work out for your needs but give it a try and report it back and i will try to assist you with what i can.