如何解决.htaccess代码点火器重定向,而无需更改URL
| 我有此htaccess代码。我想要完成的是能够将请求重定向到/ about和/ learn到/ wordpress文件夹的内容,而无需更改地址栏#Rewrite engine rules
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\\.php|import\\.php|geocode\\.php|robots\\.txt|BingSiteAuth\\.xml|y_key_88c0d00f4917d584\\.html|favicon\\.ico|images|img|uploads|css|js|topics|wordpress)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^about$ /wordpress [L]
RewriteRule ^learn$ /wordpress [L]
具有/ content作为Web根的以下结构:
/content
/wordpress
index.php (the wordpress index.php)
.htaccess (the one we are editing)
index.php (the codeigniter index.php)
但是,htacess代码不起作用。
解决方法
尝试将您的特定规则移到通配符规则之上。
目前你有
RewriteRule ^(.*)$ /index.php/$1 [L]
在您使用特定规则之前,将首先触发此规则。
至于您的特定规则(关于/学习),您可能需要重定向到/wordpress/index.php
请记住,如果您的wordpress文件夹中有一个.htaccess文件,则将使用其中一个代替CodeIgniter / Root目录中的一个,但是似乎文件列表中没有该文件。
, 事实证明,如果您重定向到wordpress根目录,则地址栏会发生变化。所以我要做的是在Wordpress中创建一个“学习”和“关于”页面,以便它们进入/ wordpress / learn和/ wordpress / about。
然后将其放在您的规则之上(就在RewriteEngine和RewriteBase声明之下):
RewriteRule ^about/$ /wordpress/$1 [L]
RewriteRule ^learn/$ /wordpress/$1 [L]
然后,对/ about和/ learn的请求将分别重定向到/ wordpress / about和/ wordpress / learn,而不会更改地址栏。
注意:这似乎在Chrome中有问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。