.htaccess redirect url to a subfolder on a subdomain with exceptions

.htaccess redirect url to a subfolder on a subdomain with exceptions - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the .htaccess redirect url to a subfolder on a subdomain with exceptions error on your web browser. Problem :


I have a CMS installed on a subdomain (say blog.domain.com). I created a site on it but the site can be accessed at (blog.domain.com/sites/mysite). I also have to use other links like blog.domain.com/#/create and blog.domain.com/#/login/mysite



How do I achieve the following things:




  1. Redirect all requests to blog.domain.com to blog.domain.com/sites/mysite WITHOUT changing the URL.

  2. Still have access to blog.domain.com/#/create and blog.domain.com/#/login/mysite



I know there are a lot of answers on .htaccess redirects but I cant find the complete answer for both my questions above.


Solution :

In your subdomains document root, try the following:



RewriteEngine On
RewriteCond %REQUEST_URI !^/sites/mysite/
RewriteRule (.*) sites/mysite/$1 [L]


Since this is an internal rewrite, you don't need to do anything with regards to #2


We hope that this article has helped you resolve the htaccess, redirects, url error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=