简体   繁体   English

重定向/index.php - wordpress

[英]Redirect /index.php - wordpress

I want that if someone got link to my site, lets say: www.bla.com/index.php , he will redirect to www.bla.com.我希望如果有人链接到我的网站,让我们说: www.bla.com/index.php ,他将重定向到 www.bla.com。 or in another words - remove the index.php.或者换句话说 - 删除 index.php。

Here is my .htaccess file:这是我的 .htaccess 文件:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^bla\.com$ [NC]
RewriteRule ^(.*)$ http://www.bla.com/$1 [L,R=301]

Either if someone got link: www.bla.com/camera/index.php - it will redirect to www.bla.com/camera/.如果有人得到链接:www.bla.com/camera/index.php - 它将重定向到 www.bla.com/camera/。

For now, the site itself works great, without index.php, but i want to remove the index.php if someone came from extern link.目前,该站点本身运行良好,没有 index.php,但如果有人来自外部链接,我想删除 index.php。

try like that in像这样尝试

.htaccess

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^bla\.com$ [NC]
RewriteRule ^(.*)$ http://www.bla.com/$1 [L,R=301]

RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
RewriteRule ^(.*)$ index.php?/$1 [L]

This post is tagged with WordPress.这篇文章被标记为 WordPress。 All of what you're looking for and doing (canonical domain, canonical url without index.php ) has been built into WordPress at least since WP 3.0 when permalinks are turned on... Look into canonical redirects -- you'll find the logic in there.至少从 WP 3.0 开始,当永久链接打开时,您正在寻找和做的所有事情(规范域,规范 url 没有index.php )已经内置到 WordPress 中......查看规范重定向- 你会发现里面的逻辑。

Try this尝试这个

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I believe the OP wants to prevent using index.php even when external links are involved.我相信即使涉及外部链接,OP 也希望阻止使用 index.php。 After following the advice from the other question.在遵循另一个问题的建议之后。 Try this.尝试这个。

RewriteRule ^(.*)/index.php$ http://www.bla.com/$1/ [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM