写重定向URL htaccess的中字preSS [英] Writing redirecting URL in htaccess in wordpress
问题描述
我目前的链接
<$p$p><$c$c>http://localhost/removalcenter/landing-page/?from=Algeria&to=Afghanistan&submit=Submit
我要重定向到这个当前的URL,当用户输入URL
的http://本地主机/ removalcenter /清除 - 从 - 阿尔及利亚对阿富汗
出租车从和被查询字符串变量
我的htaccess code是..
#BEGIN字preSS
&LT; IfModule mod_rewrite.c&GT;
RewriteEngine叙述上
的RewriteBase / removalscenter /
重写规则^指数\ .PHP $ - [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 /removalscenter/index.php [L]
&LT; / IfModule&GT;
#结束字preSS
请为我提供这个重定向规则。
你必须把这个code到你的functions.php
我没有测试一下吧!这只是一个例子,因为你问到一些code。
在,你必须去字preSS设置 - >永久链接,只保存设置。如果你不来,你会得到一个404错误。
阅读文字preSS codeX信息:
重要提示:不要忘了刷新和重新生成重写规则 修改后的规则数据库。从Word preSS管理界面, 选择设置 - >永久链接,没有任何只需点击保存更改 修改。
函数custom_rewrite_basic(){
add_rewrite_rule(^ removalcenter /着陆页/清除 - 从 - 阿尔及利亚对阿富汗/?','/ removalcenter /着陆页/距离=阿尔及利亚和放大器;以=阿富汗和放大器;提交=提交','顶');
}
add_action('init'的,'custom_rewrite_basic');
My current Url is
http://localhost/removalcenter/landing-page/?from=Algeria&to=Afghanistan&submit=Submit
I want to redirect to this current URL when the user enters URL
http://localhost/removalcenter/removals-from-Algeria-to-Afghanistan
from and to are querystring variables
My htaccess code is..
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /removalscenter/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /removalscenter/index.php [L]
</IfModule>
# END WordPress
Please provide me with the rule for this redirect.
You have to put this code into your functions.php
I didn't test it! It is only an example because you asked about some code.
After that YOU HAVE TO go to wordpress settings -> permalink and only save the settings. If you don't to that you will get a 404 error.
Read the information of wordpress codex:
IMPORTANT: Do not forget to flush and regenerate the rewrite rules database after modifying rules. From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.
function custom_rewrite_basic() {
add_rewrite_rule('^removalcenter/landing-page/removals-from-Algeria-to-Afghanistan/?', '/removalcenter/landing-page/?from=Algeria&to=Afghanistan&submit=Submit', 'top');
}
add_action('init', 'custom_rewrite_basic');
这篇关于写重定向URL htaccess的中字preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!