URL重定向在Word preSS手动编辑.htaccess文件 [英] URL redirection in Wordpress manually by editing .htaccess file

查看:177
本文介绍了URL重定向在Word preSS手动编辑.htaccess文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解决我的话preSS的问题​​之一,在PHP中的URL重定向。

please help me to fix my one of wordpress problem with URL redirecting in PHP.

这是我的原话preSS htaccess文件。

This is my original wordpress htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我想在这里创建自定义URL重定向。对于恩, 我希望重定向的页​​面,

I want to create custom URL redirection here. For ex., I want to redirect pages,

http://example.com/b/1    >     http://example.com/b?n=1
http://example.com/b/2    >     http://example.com/b?n=2

我使用的目录URL类型(如显示目录的URL不带扩展名)的字preSS设置的搜索引擎优化的选项。

i am using directory URL type (displaying URLs as directories without extensions) SEO options in wordpress settings.

http://example.com/b 页面里面,我已经包括用另一个PHP文件包括('z.php'); 命令。 Z.php 读取URL参数来源于/?N = 1'通过重定向的URL。 我试过下面的解决方案,但没有运气。

inside of http://example.com/b page, I have included another php file using ‘include(‘z.php’);’ command. Z.php is reading URL parameter comes from ‘/?n=1’ through redirected URL. I tried below solution, but no luck..

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^b/([^/]*)$ /b/?n=$1 

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

鸭preciate任何的帮助。

Appreciate any of help.

修改

字preSS头文件可以读取转换参数。我检查,通过显示在标题 GET 参数N。 但它显示的文件找不到 http://example.com/b/

wordpress header file can read the translated parameters. i checked that by displaying GET parameter 'n' in title. but it shows file not found for http://example.com/b/

我证实,通过编辑 http://example.com/b/ 页面内容。非页面内容重写后显示。

i verified that, by editing http://example.com/b/ page content. non of page content displaying after rewriting.

pciated任何帮助AP $ P $

Any help appreciated

修改

的URL可以具有参数的字符,如下

URL may have characters in parameter as below.

http://example.com/b/abc_1    >     http://example.com/b?n=abc_1
http://example.com/b/aa_2    >     http://example.com/b?n=aa_2

感谢您帮助

推荐答案

我发现这个问题的话preSS相关的解决方案。

I found the word press related solution for this question.

在字preSS所有的请求都前往自动index.php的。如果我们创建自定义的改写到另一个页面,该请求不经过index.php文件。这使得字preSS不明身份的请求,字preSS将返回找不到消息页面。

in word press all the requests are heading to index.php automatically. if we create custom rewrite to another page, that request not going through index.php. that makes wordpress unidentified request and wordpress will return page not found message.

becasue的是,我们要重定向,而不​​是永久的自定义改写为的index.php

becasue of that, we have to redirect custom rewrite to index.php instead of permalink.

我用

RewriteRule ^b/([^/]*)$ index.php?page_id=4&n=$1

这条规则重定向规则第索引页匹配的所有请求。 (我的页面ID为 / B / 4) 这个工作成功地为我。

this rule redirected all requests matched with rule to index page. (my page ID for /b/ is 4) this worked successfully for me.

其他的解决方案上面工作了非字preSS的情况。但我发现这个词preSS的行为,我解释了。

other solutions above worked for non wordpress situations. but i found wordpress behavior as i explained.

AP preciates谁试图回答。

appreciates who tried to answer.

这篇关于URL重定向在Word preSS手动编辑.htaccess文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆