简体   繁体   中英

Apache redirect to a clean URL

I have a centos webserver with Apache/2.2.15. In the past I had la login page like this http://app.website.com/index.php?resource=Login and now I changed my website and I want to redirect this page to the new one. I puted in virtual host this redirect:

RedirectPermanent / https://newapp.website.com/

And now when I access this page http://app.website.com/index.php?resource=Login I am redirected to this page http://newapp.website.com/index.php?resource=Login and I receive 404. But I want to redirect me to the clean url, without "index.php?resource=Login" just http://newapp.website.com/ . I want to solve this porblem because many users bookmarked the login page and now they receive 404 error. I will not change the website, I need a solution in apache or in .htaccess. Thanks

Redirect Directive appends trailing paths and query strings to its destination Url, Try mod_rewrite to solve this problem :

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php\?resource=Login [NC]
RewriteRule ^  http://newapp.website.com/? [NC,L,R]

Empty question mark at the end is important as it will discard the original query string from url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM