我正在尝试将此网址example.com/cow-courc-wood-alliance/register/
发送到此example.com/hotel/cow-courc-wood-alliance/register/
我试着追随没有运气:
RewriteRule ^/?cow-courc-wood-alliance/ /hotel/cow-courc-wood-alliance/register/
见htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/?cow-courc-wood-alliance/ /hotel/cow-courc-wood-alliance/register/
</IfModule>
# END WordPress
## Hide version of wordpress in html file
<files readme.html>
order allow,deny
deny from all
</files>
实际上这是wordpress example.com/hotel/
而hotel
是管理员中的一个页面,原因是example.com/hotel/
。
我在文件夹/cow-courc-wood-alliance/register/
中的wordpress root中添加了Codeigniter。这是文件夹cow-courc-wood-alliance
,register
是控制器。现在我想在这里运行我的网址example.com/hotel/cow-courc-wood-alliance/register/
答案 0 :(得分:0)
你不能用WordPress做到这一点。这是因为WP具有URL的逻辑,因此如果您重定向或重写某些内容并且WordPress不知道它,则会出现404错误。
您必须将网址更改为例如WordPress中的/hotel/cow-courc-wood-alliance/register/
,而且您可以将传入的网址(例如此/cow-courc-wood-alliance/register/
)重定向到新位置:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/?cow-courc-wood-alliance/(.*)$ /hotel/cow-courc-wood-alliance/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
您没有告诉我们您也使用其他框架。现在有了新的信息,你必须改变这样的htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Rewrite incoming URLs like /hotel/cow-courc-wood-alliance/register to the Framework Folder
RewriteRule ^/?hotel/cow-courc-wood-alliance(/.*)?$ /cow-courc-wood-alliance/$1 [L]
RewriteRule ^index\.php$ - [L]
# Folder cow-courc-wood-alliance should not go to Wordpress
RewriteCond %{REQUEST_URI} !^/?cow-courc-wood-alliance(/.*)?$ [NC]
# Folder /hotel/cow-courc-wood-alliance should not go to Wordpress
RewriteCond %{REQUEST_URI} !^/?hotel/cow-courc-wood-alliance(/.*)?$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>