[英]Wordpress and .htaccess – pretty permalinks and undefined function
我在堆棧上閱讀了幾個類似的主題,但是沒有答案能完成工作,所以:
我開始使用Wordpress並創建了第一個主題。 我將WP放置在localhost/first-wp/
和localhost/first-wp/wp-content/themes/first-theme/
我有幾個文件,例如index.php , login.php或register.php 。
現在,我想通過漂亮的永久鏈接訪問此文件,例如localhost/first-wp/login
或localhost/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中。
我該如何解決此問題,輸入漂亮的永久鏈接而不會出現此錯誤? 感謝您的所有建議。
您正在使用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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.