dsb0003795 2018-10-03 11:36
浏览 203

如何将所有请求重定向到另一个URL的子路径?

I have a folder in which I store user profile pages. For example, the profile page for the user "JohnDoe" is:

mywebsite.com/user/JohnDoe/index.php

I want to redirect all requests to mywebsite.com/user/*/index.php to mywebsite.com/user/index.php.

I read this post and tried redirecting to google.com as a test:

Redirect 301 /user google.com

but this redirects to mywebsite.com/google.com/JohnDoe/index.php.

I then cleared my browser's cache and tried:

Redirect 301 /user https://www.google.com

Simply put, I am looking for something like:

Redirect 301 /user/*/index.php /user/index.php

but I am not getting redirected. Unfortunately I couldn't find this in the forums. How do I accomplish this, without the existence of the user profile page?

  • 写回答

1条回答 默认 最新

  • dsfs64664 2018-10-03 11:54
    关注

    Hope this will help you

    put this code in .htaccess

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
    RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
    

    from http://www.webconfs.com/154/301-redirects-how-to-redirect-your-website/

    评论

报告相同问题?