[英]htaccess file not working for wordpress pages
我正在嘗試在htaccess文件中添加新規則,該規則允許輸入other
而不是notify
頁面的實際名稱。 但是我似乎無法使其正常工作。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^other$ notify [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
還嘗試了類似的東西:
RewriteRule ^other$ index.php/notify [QSA]
和這個:
RewriteRule ^other$ /index.php/notify [QSA]
還嘗試從wordpress本身(在插件的admin_init部分內部)添加規則,然后通過轉到永久鏈接設置,選擇帖子名稱然后保存但也沒有運氣來刷新規則。 檢查htaccess文件后,它產生了與上述規則相似的規則:
add_rewrite_rule('other', 'index.php/notify', 'bottom');
我已經驗證可以通過根目錄中的htaccess文件覆蓋規則,因為當我嘗試在服務器hello.php
使用實際文件時
RewriteRule ^other$ hello.php [QSA]
有用。 我只是不知道為什么當我使用wordpress頁面時它不起作用。 當我使用絕對路徑時,它似乎也起作用:
RewriteRule ^other$ http://somesite.com/notify [QSA]
但這不好,因為當我向URL添加一些參數時(最終將要這樣做),當執行上述操作時,我的URL最終看起來很糟糕: http : //somesite.com/?some_argument=some_value
Wordpress中的當前永久鏈接設置被設置為帖子名稱。 有什么想法我錯過了嗎?
嘗試以下規則:
RewriteRule ^other/?$ index.php?p=PAGE_ID [QSA]
放置必要的PAGE_ID以重定向到
您好,您可以使用.htaccess插件..! 從管理面板進行控制。 希望這對您有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.