网站重定向问题

时间:2013-04-12 16:25:49

标签: php html5 wordpress .htaccess

我一直在开发一个主要基于PHP的网站。当用户访问网站内容http://robroscoe.ca/index.php时,会重定向到http://robroscoe.ca,我对此感到满意。当我输入robroscoe.ca/cv.php重定向回robroscoe.ca/cv时,我的网页就像robroscoe.ca一样。我不确定这是怎么发生的,我想知道是否有人可以向我解释发生了什么。

# 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]
</IfModule>

# END WordPress

我认为.htaccess文件与此有关但我不知道如何修改它,因为Wordpress似乎在我不知情的情况下为我创建了这个。任何帮助或阅读材料将不胜感激。

谢谢你的时间!

1 个答案:

答案 0 :(得分:1)

你的问题是你创建了一个与WordPress 分开的的PHP脚本,并试图通过WordPress处理的“漂亮”URL访问它。 WordPress不知道一个名为'cv'的页面,并且像任何其他404一样处理它。

强烈建议您在WP中创建页面,以便它可以管理自己的“漂亮网址”结构。

如果你想要自己编写脚本,那么就可以手动编辑每个脚本的.htaccess文件。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^cv/?$ cv.php [L]   #new rule
RewriteRule ^index\.php$ - [L]  #this is made redundant by the very next line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>