【问题标题】:I want to use rewriterule to redirect this url to this url我想使用 rewriterule 将此网址重定向到此网址
【发布时间】:2022-01-26 15:31:01
【问题描述】:

http://domain.co.kr/areasearch?sfl=wr_7&stx=apple

我想使用 rewriterule 将这个 url 重定向到这个 url

http://domain.co.kr/areasearch/wr_7/apple

我在底部添加了下面的重写正则表达式

重写规则 ^/([^/]+)/([^/]+)/?$ areasearch?sfl=$1&stx=$2 [QSA,L]

当我访问下面的 url 时,我得到一个 Not Found The requested URL /wr_7/apple was not found on this server.什么问题?

http://domain.co.kr/areasearch/wr_7/apple

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^shop/list-([0-9a-z]+)$  shop/list.php?ca_id=$1&rewrite=1  [QSA,L]
RewriteRule ^shop/type-([0-9a-z]+)$  shop/listtype.php?type=$1&rewrite=1  [QSA,L]
RewriteRule ^shop/([0-9a-zA-Z_\-]+)$  shop/item.php?it_id=$1&rewrite=1  [QSA,L]
RewriteRule ^shop/([^/]+)/$  shop/item.php?it_seo_title=$1&rewrite=1  [QSA,L]
RewriteRule ^content/([0-9a-zA-Z_]+)$  bbs/content.php?co_id=$1&rewrite=1  [QSA,L]
RewriteRule ^content/([^/]+)/$  bbs/content.php?co_seo_title=$1&rewrite=1      [QSA,L]
RewriteRule ^rss/([0-9a-zA-Z_]+)$  bbs/rss.php?bo_table=$1        [QSA,L]
RewriteRule ^([0-9a-zA-Z_]+)$  bbs/board.php?bo_table=$1&rewrite=1      [QSA,L]
RewriteRule ^([0-9a-zA-Z_]+)/([^/]+)/$ bbs/board.php?bo_table=$1&wr_seo_title=$2&rewrite=1      [QSA,L]
RewriteRule ^([0-9a-zA-Z_]+)/write$  bbs/write.php?bo_table=$1&rewrite=1    [QSA,L]
RewriteRule ^([0-9a-zA-Z_]+)/([0-9]+)$  bbs/board.php?bo_table=$1&wr_id=$2&rewrite=1  [QSA,L]
RewriteRule ^/([^/]+)/([^/]+)$ areasearch?sfl=$1&stx=$2 [QSA,L]
</IfModule>

【问题讨论】:

  • “我想使用 rewriterule 将此 url 重定向到此 URL” - 尽管您尝试实施的规则完全相反?

标签: php mod-rewrite


【解决方案1】:

您的正则表达式 (^/([^/]+)/([^/]+)$) 与 areasearch/wr_7/apple 不匹配

您可能错过了您的网址以 areasearch/ 开头,所以这应该可以工作

^areasearch/([^/]+)/([^/]+)$

【讨论】:

    猜你喜欢
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2019-04-08
    • 2016-09-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    相关资源
    最近更新 更多