Mobile app version of vmapp.org
Login or Join
Si4351233

: 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

@Si4351233

Posted in: #301Redirect #Htaccess

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

...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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme