![Si4351233](https://vmapp.org/images/player/000default.jpg)
: Redirect a set of dir to single page Suppose I have example.com and removed 5 directories.They consist a lot of URL.Because I give penalty from google search engine, I decide to create a page
Suppose I have example.com and removed 5 directories.They consist a lot of URL.Because I give penalty from google search engine, I decide to create a page and redirect (permanent 301) those to my page.
As you know, I have to use .htaccess , But I use the following rule:
RedirectMatch 301 /old-directory/(.*) /new-directory/
Unlike of above rule, I need to redirect to new page, not new dir.
How to implement it?
More posts by @Si4351233
1 Comments
Sorted by latest first Latest Oldest Best
...I get penalty from google search engine
The "penalty" is probably just that you have removed a lot of your content! Naturally, if these pages were previously indexed and receiving search engine traffic then you are going to lose visitors.
However, redirecting all these lost pages to a single "irrelevant" page is probably not going to help either. That's probably not going to be a good user experience and Google will soon realise the page being redirected to is unrelated, so will probably just drop it anyway.
If you don't have a new version of these pages to redirect to then you are perhaps better off customising your "custom 404" some more with more relevant information for the user in the hope that they will stick around.
Coming back to the technical aspect of redirecting 5 directories to a single page:
RedirectMatch 301 ^/(olddir1|olddir2|olddir3|olddir4|olddir5)/ /path/to/new/page
You basically just need to remove the from the URL substitution in your original code.
Note that if you already have some RewriteRule directives then you should probably be using mod_rewrite instead of mod_alias in order to prevent conflicts.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.