重定向内容而不更改 htaccess 文件中的 url
Redirecting content without changing url in htaccess file
在我们的 Wordpress 上,我们希望 url 指向 :
- 从 mysite/education/somethingelse
- 到mysite/somethingelse
但 无需为用户更改 url。
我试过了:
RewriteRule ^education/(.*) / [R=301]
和
RewriteCond %{REQUEST_URL} /education
RewriteRule ^(.*) [P]
.htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# RewriteRule ^education/(.*) / [R=301]
# RewriteCond %{REQUEST_URL} /education
# RewriteRule ^(.*) [P]
# RewriteRule /education ^$ [L]
# RewriteRule /education ^$ [R=301,NC,L]
# RewriteCond %{HTTP_HOST} /education
# RewriteRule ^(.*) [P]
RewriteRule ^/education/(.*) /
</IfModule>
它没有用:它重定向到新的 url 但它一直在变化 url !
有什么想法吗?
根据此规则修改您的重写
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^education\/(.*) / [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
在我们的 Wordpress 上,我们希望 url 指向 :
- 从 mysite/education/somethingelse
- 到mysite/somethingelse
但 无需为用户更改 url。
我试过了:
RewriteRule ^education/(.*) / [R=301]
和
RewriteCond %{REQUEST_URL} /education
RewriteRule ^(.*) [P]
.htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# RewriteRule ^education/(.*) / [R=301]
# RewriteCond %{REQUEST_URL} /education
# RewriteRule ^(.*) [P]
# RewriteRule /education ^$ [L]
# RewriteRule /education ^$ [R=301,NC,L]
# RewriteCond %{HTTP_HOST} /education
# RewriteRule ^(.*) [P]
RewriteRule ^/education/(.*) /
</IfModule>
它没有用:它重定向到新的 url 但它一直在变化 url !
有什么想法吗?
根据此规则修改您的重写
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^education\/(.*) / [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>