我有这个htaccess代码。我想要完成的是能够将请求重定向到/关于和/了解/ 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代码不起作用。
答案 0 :(得分:0)
尝试将您的特定规则移到通配符规则之上。
目前你有
RewriteRule ^(.*)$ /index.php/$1 [L]
在您的特定规则之前,将首先触发此规则。 至于你的具体规则(关于/学习),你可能想要重定向到/wordpress/index.php
请记住,如果你的wordpress文件夹有一个.htaccess文件,那么将使用一个文件而不是你的CodeIgniter / Root文件,但是它似乎没有通过你的文件列表。
答案 1 :(得分:0)
事实证明,如果您重定向到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中存在问题。