【问题标题】:Wordpress and .htaccess – pretty permalinks and undefined functionWordpress 和 .htaccess – 漂亮的永久链接和未定义的功能
【发布时间】:2015-02-27 23:23:17
【问题描述】:

我在堆栈上阅读了几个类似的主题,但没有一个答案能起到作用,所以:

我开始使用 Wordpress 并创建了我的第一个主题。我已将 WP 放入 localhost/first-wp/localhost/first-wp/wp-content/themes/first-theme/ 我有几个文件,例如 index.phplogin.phpregister.php

现在,我想通过漂亮的永久链接访问这些文件,例如 localhost/first-wp/loginlocalhost/first-wp/register

我在localhost/first-wp/ 中创建了 .htaccess 文件,并在其中放置了以下内容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /first-wp/
RewriteRule ^index\.php$ - [L]
RewriteRule ^login? /first-wp/wp-content/themes/first-theme/login.php [QSA,L]
RewriteRule ^register? /first-wp/wp-content/themes/first-theme/register.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /first-wp/index.php [L]
</IfModule>

但问题是,当我输入例如localhost/first-wp/login 时,我收到错误:Call undefined function 'my_simple_func()' in /Applications/XAMPP/xamppfiles/htdocs/first-wp/wp-content/themes/first-theme/login.php。 这个函数当然放在我的主题目录的functions.php中。

如何解决这个问题,输入漂亮的固定链接而不出现这个错误? 感谢所有建议。

【问题讨论】:

    标签: php wordpress .htaccess


    【解决方案1】:

    您正在使用 RewriteBase 复制您的目录。

    试试:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /first-wp/
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^login? wp-content/themes/first-theme/login.php [QSA,L]
    RewriteRule ^register? wp-content/themes/first-theme/register.php [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    </IfModule>
    

    【讨论】:

    • 哇,这么简单。谢谢你,先生!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-30
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多