htaccess的重定向不改变网址

编程入门 行业动态 更新时间:2024-10-23 09:23:16
本文介绍了htaccess的重定向不改变网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个URL像

www.mydomain/state$c$c1-folder1

我想将其重定向到/文件夹1 /页,但我想说明的原始网址如上在浏览器地址栏。

请注意,我没有文件夹状态code1-文件夹1和国家code2-文件夹1

目前我用的是下面的.htaccess会被重定向,但它改变地址栏

#Options +的FollowSymLinks RewriteEngine叙述上 的RewriteBase / 的RewriteCond%{REQUEST_URI} ^ /状态code1-文件夹1 $ 重写规则^(+)/文件夹1 [L] 的RewriteCond%{REQUEST_URI} ^ /状态code2-文件夹1 $ 重写规则^(+)/文件夹1 [L]

解决方案

您不应该有斜线后面的空间!而故事的结局$也许这是什么问题?通常情况下,当地的重定向应该工作。尝试是这样的:

RewriteEngine叙述上 的RewriteBase / 的RewriteCond%{REQUEST_URI} ^ /状态code1-文件夹1 重写规则^ * /文件夹1 [L] 的RewriteCond%{REQUEST_URI} ^ /状态code2-文件夹1 重写规则^ * /文件夹1 [L]

I have few urls like

www.mydomain/statecode1-folder1

I want to redirect it to /folder1/ page but I want to show the the original urls as above in the browser address bar.

Please note that I do not have folders statecode1-folder1 and statecode2-folder1

Currently I use the below .htaccess which redirects but it changes the address bar

#Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/ statecode1-folder1 $ RewriteRule ^(.+) / folder1 [L] RewriteCond %{REQUEST_URI} ^/ statecode2-folder1 $ RewriteRule ^(.+) / folder1 [L]

解决方案

You shouldn't have spaces after slash! And the ending $ Maybe it is the problem? Normally, local redirect should work. Try something like this:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/statecode1-folder1 RewriteRule ^.* /folder1 [L] RewriteCond %{REQUEST_URI} ^/statecode2-folder1 RewriteRule ^.* /folder1 [L]

更多推荐

htaccess的重定向不改变网址

本文发布于:2023-10-31 12:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不改变   重定向   网址   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!