写重定向URL htaccess的中字preSS中字、重定向、htaccess、URL

2023-09-02 01:14:15 作者:做你的痛处

我目前的链接

http://localhost/removalcenter/landing-page/?from=Algeria&to=Afghanistan&submit=Submit

我要重定向到这个当前的URL,当用户输入URL 的http://本地主机/ removalcenter /清除 - 从 - 阿尔及利亚对阿富汗出租车从和被查询字符串变量 我的htaccess code是..

 #BEGIN字preSS
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase / removalscenter /
重写规则^指数 .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 /removalscenter/index.php [L]
< / IfModule>
#结束字preSS
 

请为我提供这个重定向规则。

解决方案

你必须把这个code到你的functions.php

我没有测试一下吧!这只是一个例子,因为你问到一些code。

301重定向代码写在哪

在,你必须去字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-Afghanistanfrom 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');