Can I redirect the HTTP request towards an old folder to the homepage using .htaccess file?

Can I redirect the HTTP request towards an old folder to the homepage using .htaccess file? - 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 Can I redirect the HTTP request towards an old folder to the homepage using .htaccess file? error on your web browser. Problem :


I have to following situation: I had an old blog that was made using Joomla (this blog was indexed well enough by search engines). For some problems I delete it and I have create it again using WordPress.



Now I have many visit (from Google) that leading to specific pages of the old site (pages that don't exist in the new version).



For example I have visit to URL as: /scorejava/index.php/corso-spring-mvc/1-test that don't exist on my new site.



I would know if using the .htaccess file (or other sistem) I can redirect the HTTP request directed to some subfolder (that don't exist in the new version) to the homepage of my new site.



For example I have the request towards the void URL: /scorejava/index.php/corso-spring-mvc/1-test.



And I would create a regular expression that say something like: all the request toward the subfolder corso-spring-mvc (and all it's content file and subfolder) have to be redirected to www.scorejava.com.



Is it possible?


Solution :

You need something like this:



RewriteEngine On
RewriteRule ^.*/corso-spring-mvc/ [R=301,L]


The regular expression can be pretty much anything. Whatever matches will be redirected to the root of your site, represented by / and the browser will get a 301 permanent redirect.



Now, I suspect you should try a more generic rule, otherwise you'll have a lot of them to write. If the old blog was under /scorejava/* for example, then you only need a rule like:



RewriteRule ^/score_java/ [R=301,L]

We hope that this article has helped you resolve the apache, htaccess, redirects 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=