.htaccess - 如何使用 htaccess 将 example.com/x/restofurl 重定向到 example.com/y/restofurl

标签 .htaccess http-redirect

我有一个类似于 example.com/x

的网址

如何使用 htaccess 将其重定向到 example.com/y

顺便说一句,我不想​​丢失其余的网址。

当前 .htaccess 文件看起来像;

<ifModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]

</ifModule>

最佳答案

查看 documentation :

RewriteEngine on
RewriteRule ^/x/(.+) /y/$1 [R,L]

关于.htaccess - 如何使用 htaccess 将 example.com/x/restofurl 重定向到 example.com/y/restofurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13221806/

相关文章:

php - 如何在浏览器 URL 显示中隐藏目录的索引页

.htaccess - 如何使用htaccess从https翻转为http

java - 使用 Rest Assured 获取重定向的 url?

android - 在 Android 中向 wordpress 博客发表评论

iis-7.5 - 将子域 URL 重定向到 IIS 中的另一个子域

java - 返回集群环境下的servlet

.htaccess 在删除 php 扩展和内部重定向时抛出文件夹

.htaccess - 不影响ajax功能的URL重写

.htaccess - 当人们访问网站商店时如何强制非 www

asp.net-mvc-5 - ASP.NET MVC 5 将 Web SSO 与外部 IDP 结合使用 - WS Fed 元数据未解析